aio-libs / aio-libs/aiohttp-cors

Only 1 is allowed

Đang mở
#271 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
220
Fork
61
Merge trung bình
2 phút
Pull request đã merge (30 ngày)
3

Mô tả

Hello,
I am trying to work on a project, and I am facing an issue.
The problem is that when I am requesting a resource from the server, google chrome is saying that the "Access-Control-Allow-Origin' header contains multiple values"
This is my code

```
@asyncio.coroutine
def handler(request):
return web.Response(
text="Hello!",
headers={
"X-Custom-Server-Header": "Custom data",
})

app = web.Application()

cors = aiohttp_cors.setup(app)

resource = cors.add(app.router.add_resource("/"))

route = cors.add(
resource.add_route("POST", handler), {
"*": aiohttp_cors.ResourceOptions(allow_methods="*",
allow_headers=("X-Requested-With", "Content-Type", "AUTHORIZATION"),
expose_headers="*",
allow_credentials=False
)
})
if __name__ == '__main__':
web.run_app(app, port=os.getenv("PORT"), host='0.0.0.0')
```
i am serving aiohttp over nginx

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.