django-eventstream icon indicating copy to clipboard operation
django-eventstream copied to clipboard

Multiple Header Support

Open Jay206-Programmer opened this issue 2 years ago • 3 comments

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

Jay206-Programmer avatar Apr 08 '22 11:04 Jay206-Programmer

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'.

jkarneges avatar Apr 22 '22 02:04 jkarneges