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:
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Ζ‘...
Jump to solution
7 Replies
Percy
Percyβ€’7mo ago
Project ID: b1d6fa08-43ff-4114-82f0-f836e0ee2651
Brody
Brodyβ€’7mo ago
are you using gunicorn?
Solution
Ivanyan 🌴
Ivanyan πŸŒ΄β€’7mo ago
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Ζ‘
Brody
Brodyβ€’7mo ago
it depends, are you using gunicorn for flask?
Ivanyan 🌴
Ivanyan 🌴OPβ€’7mo ago
Yes, I'm using gunicorn
Ivanyan 🌴
Ivanyan 🌴OPβ€’7mo ago
Thank you a lot for your support :salute:
Brody
Brodyβ€’7mo ago
no prob please do not close threads
Want results from more Discord servers?
Add your server