CORS issue calling to railway from other domain
Project ID : b1d6fa08-43ff-4114-82f0-f836e0ee2651
Hi, I'm getting this error when trying to call from my frontend to Flask backend server hosted on Railway:
Access to fetch at 'http://c...pp/1980' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
Here is my flask server looks like:
------------------ SETUP ------------------
load_dotenv()
app = Flask(__name__)
# this will need to be reconfigured before taking the app to production
cors = CORS(app, resources={r"/*": {"origins": ["http://localhost", "http://localhost:3000", "http://c...pp"]}})
...
# ------------------ START SERVER ------------------
if __name__ == '__main__':
app.run(debug=True, port=os.getenv("PORT", default=5000))
Do you have any suggestion?
Anyway, thank you for building amazing railway!Solution:Jump to solution
I figured it out. On the front end, I actually called to
http://c...pp/1980
though it should be https://c...pp/1980
This was a typo as my code was generated by Copilot
My railway server took the http request, redirected to make it https. That's why we got the Redirect is not allowed for a preflight request.
error
We can mark my problem as solved nΖ‘...7 Replies
Project ID:
b1d6fa08-43ff-4114-82f0-f836e0ee2651
are you using gunicorn?
Solution
I figured it out. On the front end, I actually called to
http://c...pp/1980
though it should be https://c...pp/1980
This was a typo as my code was generated by Copilot
My railway server took the http request, redirected to make it https. That's why we got the Redirect is not allowed for a preflight request.
error
We can mark my problem as solved nΖ‘it depends, are you using gunicorn for flask?
Yes, I'm using gunicorn
Thank you a lot for your support :salute:
no prob
please do not close threads