Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Header Support #91

Open
Jay206-Programmer opened this issue Apr 8, 2022 · 3 comments
Open

Multiple Header Support #91

Jay206-Programmer opened this issue Apr 8, 2022 · 3 comments

Comments

@Jay206-Programmer
Copy link

In my web application, the Frontend needs to send multiple custom headers (Ex. username, userid, pagename, etc.) for authorization & other use cases.

The Normal Rest Api (GET, POST) communication with the server is working fine, but the Server Sent Event connection is giving CORS error in the preflight request.
image

I am using django-cord-headers together with eventstream cors flags to handle CORS. Here are my configs in the settings.py:

8d366770-fe0c-4276-99ab-cd20505e620e

9b666a67-9398-4707-8e0c-2cfdb87a55ce

I believe that the CORS_ALLOWED_HEADERS doesn't work with eventstream. But also at the same time, the EVENTSTREAM_ALLOW_HEADER only takes one header as mentioned here.

What can I do if I want to allow multiple headers (Ex. username, pagename, userid) in the eventstream as well?

Below is my asgi.py file:
91ac075d-1adc-4212-ba31-17708d90dda2

@jkarneges
Copy link
Member

The docs are a little confusing. The EVENTSTREAM_ALLOW_HEADERS option is used as the value of the Access-Control-Allow-Headers response header. It is a single string value, but that value can be something like 'Header1, Header2'.

@nasir-fs
Copy link

nasir-fs commented Aug 3, 2023

@jkarneges I tried your suggestion but still getting CORS issues.
Access to resource at 'https://dev-communicationapi.cleverstack.in/api/events/' from origin 'http://localhost:3000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:3000,http://127.0.0.1:3000,https://cleverstack.in,https://dev-auth.cleverstack.in,https://home.cleverstack.in,https://dev-app.cleverstack.in,https://dev-communicationapi.cleverstack.in', but only one is allowed.

@jkarneges
Copy link
Member

Access-Control-Allow-Origin is different from Access-Control-Allow-Headers. Probably only one value is allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants