ck 4 年之前
父節點
當前提交
b3488f7be9
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      handlers/HandlerBase.py

+ 3 - 1
handlers/HandlerBase.py

@@ -14,10 +14,12 @@ class BaseHandler(RequestHandler):
         self._status_code = 200
         self.executor = ThreadPoolExecutor(200)
         self.settings['allow_remote_access']=True
+        origin_url = self.request.headers.get('Origin')
         self.set_header('Content-Type', 'application/json')
         self.set_header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS")
         self.set_header("Access-Control-Allow-Headers", "Content-Type, Depth, User-Agent, Token, Origin, X-Requested-With, Accept, Authorization, admin_id")
-        self.set_header('Access-Control-Allow-Origin', "*")
+        self.set_header('Access-Control-Allow-Origin', origin_url)
+        self.set_header("Access-Control-Allow-Credentials", "true")
 
     def write_json(self, data, status_code=200, msg='success'):
         self.write(json.dumps({'status': {'msg': msg, "RetCode": status_code}, 'data': data}))