This commit is contained in:
yumoqing 2023-06-08 12:06:38 +08:00
parent 494a3eb8f8
commit 5156138571

View File

@ -79,10 +79,15 @@ class BaseProcessor(AppLogger):
await self.datahandle(request) await self.datahandle(request)
return self.content return self.content
def set_response_headers(self, response):
response.headers['Access-Control-Expose-Headers'] = 'AIOHTTP_SESSION'
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Control-Allow-Origin'] = '47.93.12.75'
async def handle(self,request): async def handle(self,request):
await self.execute(request) await self.execute(request)
if self.retResponse is not None: if self.retResponse is not None:
self.retResponse.headers['Access-Control-Expose-Headers'] = 'Set-Cookie' self.set_response_headers(self.retResponse)
return self.retResponse return self.retResponse
elif type(self.content) == type({}) : elif type(self.content) == type({}) :
self.content = json.dumps(self.content, self.content = json.dumps(self.content,
@ -93,7 +98,9 @@ class BaseProcessor(AppLogger):
self.headers['Content-Type'] = "application/json; utf-8" self.headers['Content-Type'] = "application/json; utf-8"
self.headers['Access-Control-Expose-Headers'] = 'Set-Cookie' self.headers['Access-Control-Expose-Headers'] = 'Set-Cookie'
return Response(text=self.content,headers=self.headers) resp = Response(text=self.content,headers=self.headers)
self.set_response_headers(resp)
return resp
async def datahandle(self,request): async def datahandle(self,request):
self.debug('*******Error*************') self.debug('*******Error*************')