Curious CORS Issue FastAPI/React with TypeScript

I get this "Mixed Content: The page at '<URL>' was loaded over HTTPS, but requested an insecure resource '<URL>'. This request has been blocked; the content must be served over HTTPS." error despite specifically fetching endpoints starting with https. My FastAPI code is set up to allow CORS. I can CURL my endpoints successfully and my website works on mobile (iOS safari), just not on desktop (Google Chrome, Safari, Edge after asking a friend). There seems to have this odd issue where my requests are made with http on Chrome/Safari despite specifically hard coding https, 200s are sent back, then select desktop browsers see them as a man in the middle attack and block responses.
I've been troubleshooting for the past hours and would like to know if you have experienced this or can lead me to clues?
13 Replies
Percy
Percy2y ago
Project ID: 5d7f21cf-aa01-4a70-bdf8-ab8cf987130e
CHRIST IS KING
CHRIST IS KINGOP2y ago
5d7f21cf-aa01-4a70-bdf8-ab8cf987130e
Brody
Brody2y ago
can you show me the error in the browser console? the screenshot is a bit cut off okay now show me the js code that actually makes a request to the projects endpoint
CHRIST IS KING
CHRIST IS KINGOP2y ago
No description
No description
No description
CHRIST IS KING
CHRIST IS KINGOP2y ago
I can make callbacks in useQuery hooks with or without async and they both lead to this.
Brody
Brody2y ago
okay now console log those endpoint variables before fetch because it's clear to see you have used https when defining the variable, we just need to find out at what stage https is getting stripped away from the variable that's completely swapped now the errors in that screenshot are completely expected though
CHRIST IS KING
CHRIST IS KINGOP2y ago
Yes due to the restrictions I put in place when using localhost:5173
Brody
Brody2y ago
you just need to find out what code is inverting https <--> http
CHRIST IS KING
CHRIST IS KINGOP2y ago
This website is deployed Yeah What strikes me as odd is how it works on iOS's safari and on Edge on a friend's desktop. My Mac's Chrome and Safari both see this
Brody
Brody2y ago
well I can confidently say that this isn't an issue with railway at least so yeah just do some digging, find out what's swapping http <--> https
CHRIST IS KING
CHRIST IS KINGOP2y ago
thanks for your help Brody I'm still hunting for the bug
Brody
Brody2y ago
I wish you good luck
Yuri Achermann
Yuri Achermann15mo ago
Hi @pepecopter, could you solve that?
Want results from more Discord servers?
Add your server