-
Notifications
You must be signed in to change notification settings - Fork 140
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
Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include' #200
Comments
Update: Adding the following code works, is there a way to do this with flask-cors so I don't need to ways of allowing cross-origin?
|
Sorry for the delay!
|
@corydolphin I have the same error. I have built na application and If I test request using Postman or Insonia it works normally, the application receive the requests and store the data in the session / database, but if I try to make a request from a React application using Axios I receive an error and the application doesn't receive any request or store data. Error :
Flask application config : # Imports
from flask import Flask
from flask_cors import CORS
# Cors
config = {
'ORIGINS': [
'http://localhost:8080', # React
'http://127.0.0.1:8080', # React
],
'SECRET_KEY': '...'
}
# App
app = Flask('Test')
CORS(app, resources={ r'/*': {'origins': config['ORIGINS']}}, supports_credentials=True) Request in React : axios({
method: 'post',
url: `127.0.0.1:5000/logout`,
headers: {Authorization: `Bearer ${this.state.login.access_token}`},
withCredentials: true // True otherwise I receive another error
}).then(response => {
console.log('Logout ', response);
}) I have also research but I don't know how to solve this. Obs ¹ : I'm using server side session (Flask Session) Obs ² : The other error is a 500. It happens because I try to get something from session to make the logout, but the attribute is not found in session (if I make the request with the tool I mentioned, it works fine). |
@sphinxs Were you able to rectify the issue? I have the same error and setup. |
Yes, besides If I remember well I have also added other parameter in the |
Please can you add something in the documentation that explains how to do it? I tried adding CORS_SUPPORTS_CREDENTIALS = True to the documentation and nothing happens. I don't understand why flask-cors does not work with axios by default, and why there is nothing in the documentation which provides a minimum working configuration for flask-cors. If the library does not even allow the application to handle the preliminary OPTIONS request, what is the point of it? |
I have the same problem too, |
|
frankly, the delete request does not work.
but the rest of the requests are processed fine.
thanks in advance
Воскресенье, 7 ноября 2021, 20:13 +04:00 от Givanchi ***@***.***>:
I have the same problem too, who knows if there are other alternatives like a flask-cors, but to work fine?
CORS_ALLOW_ORIGIN="*,*"
CORS_EXPOSE_HEADERS="*,*"
CORS_ALLOW_HEADERS="content-type,*"
cors = CORS(app, origins=CORS_ALLOW_ORIGIN.split(","), allow_headers=CORS_ALLOW_HEADERS.split(",") , expose_headers= CORS_EXPOSE_HEADERS.split(","), supports_credentials = True)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub , or unsubscribe .
Triage notifications on the go with GitHub Mobile for iOS or Android .
--
Emil Hambardzumyan
|
This comment is not directly related to the question, but it is a subcase of CORS issues. I have seen this error many times before, so I will share it and hope it will help someone. `from flask import Flask from db import db app = Flask(name) It will work perfectly fine. However you can still see errors like this in the front-end app console: In this case, you should check the URL itself and the missing trailing slash. |
Not sure why I'm getting this error when trying to allow CORS on my flask app. Here's my server:
Now on my frontend, when I attempt to make a POST request to
/img
, I get the error in the title. The full error is:The text was updated successfully, but these errors were encountered: