Curious CORS Issue FastAPI/React with TypeScript

PPepecopter5/22/2023
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?
PPepecopter5/22/2023
5d7f21cf-aa01-4a70-bdf8-ab8cf987130e
Bbrody5/22/2023
can you show me the error in the browser console?
Bbrody5/22/2023
the screenshot is a bit cut off
Bbrody5/22/2023
okay now show me the js code that actually makes a request to the projects endpoint
PPepecopter5/22/2023
PPepecopter5/22/2023
I can make callbacks in useQuery hooks with or without async and they both lead to this.
Bbrody5/22/2023
okay now console log those endpoint variables before fetch
Bbrody5/22/2023
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
Bbrody5/22/2023
that's completely swapped now
Bbrody5/22/2023
the errors in that screenshot are completely expected though
PPepecopter5/22/2023
Yes due to the restrictions I put in place when using localhost:5173
Bbrody5/22/2023
you just need to find out what code is inverting https <--> http
PPepecopter5/22/2023
This website is deployed
PPepecopter5/22/2023
Yeah
PPepecopter5/22/2023
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
Bbrody5/22/2023
well I can confidently say that this isn't an issue with railway at least
Bbrody5/22/2023
so yeah just do some digging, find out what's swapping http <--> https
PPepecopter5/22/2023
thanks for your help Brody I'm still hunting for the bug
Bbrody5/22/2023
I wish you good luck