I use react/express with django as backend.
I am trying to integrate s3 fine uploader and i am getting this issue :Request header field Cache-Control is not allowed by Access-Control-Allow-Headers in preflight response when trying to get signature from django,in a post request.
Normally i make all my request in code using fetch but here i make use of the package https://github.com/FineUploader/react-fine-uploader and it make use of xhr ? any one ran into this issue
Synopsis
ERROR: Request header field Cache-Control is not allowed by Access-Control-Allow-Headers in preflight response.
Frontend:React/express/webpack
Backend:Dajngo
Environment:Local (django server,react local api)
cause: xhr?
The CORS request requires that the server permit the use of credentials, but the server's Access-Control-Allow-Credentials header's value isn't set to true to enable their use. To fix this problem on the client side, revise the code to not request the use of credentials.
The Access-Control-Expose-Headers response header allows a server to indicate which response headers should be made available to scripts running in the browser, in response to a cross-origin request. Only the CORS-safelisted response headers are exposed by default.
The Allow header lists the set of methods supported by a resource. This header must be sent if the server responds with a 405 Method Not Allowed status code to indicate which request methods can be used.
Your problem is in the backend. Seems like the api you are trying to use is written in django.
The api owner needs to explicitly add that header into the CORS_ALLOW_HEADERS settings. I had the same issue with the Content-Disposition header while uploading images. This is my settings:
CORS_ALLOW_HEADERS = ('content-disposition', 'accept-encoding',
'content-type', 'accept', 'origin', 'authorization')
In your case, that setting needs to include 'cache-control'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With