question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

has been blocked by CORS policy: Request header field cache-control is not allowed by Access-Control-Allow-Headers in preflight response.

See original GitHub issue

has been blocked by CORS policy: Request header field cache-control is not allowed by Access-Control-Allow-Headers in preflight response.

settings.py

EVENTSTREAM_ALLOW_ORIGIN = "*"
EVENTSTREAM_ALLOW_CREDENTIALS = False

# this is for corsheaders (pip)
CORS_ORIGIN_ALLOW_ALL = True

is something wrong with the setitng? or its causing cors iissue cause it’s asgi? other api are worling file, just /event does not work…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
piotrsynowieccommented, Mar 11, 2020

Here’s the solution: https://stackoverflow.com/questions/45118468/request-header-field-cache-control-is-not-allowed-by-access-control-allow-header

You probably need to add this to settings.py:

from corsheaders.defaults import default_headers

CORS_ALLOW_HEADERS = default_headers + ('cache-control',)

the last one is what you need, the rest I assume is default.

0reactions
Jay206-Programmercommented, Apr 8, 2022

I need to set multiple headers for my preflight response Ex: username, userid, pagename etc. How can I achieve that? Because as far as I know the EVENTSTREAM_ALLOW_HEADERS only takes a single string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Request header field Access-Control-Allow-Headers is not ...
This is a request that uses the HTTP OPTIONS verb and includes several headers, one of which being Access-Control-Request-Headers listing the headers the...
Read more >
Request header field content-type is not allowed by Access ...
My netlify function has these headers set up: const headers = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': ...
Read more >
Access-Control-Allow-Headers - HTTP - MDN Web Docs
This header is required if the request has an Access-Control-Request-Headers header. Note: CORS-safelisted request headers are always allowed ...
Read more >
Resolve the "No 'Access-Control-Allow-Origin' header" error ...
If you still see errors after updating your CORS policy and forwarding the appropriate headers, allow the OPTIONS HTTP method in your distribution's...
Read more >
CORS and the Access-Control-Allow-Origin response header
Under certain circumstances, when a cross-domain request includes a non-standard HTTP method or headers, the cross-origin request is preceded by a request using ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found