django-eventstream
django-eventstream copied to clipboard
Multiple Header Support
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.
I am using django-cord-headers together with eventstream cors flags to handle CORS. Here are my configs in the settings.py:
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:
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'.