Friday, 7 June 2024

Mixed Content error

I would like to share a very tricky error one might encounter. I use React for my frontend and Flask for my backend. I run my website through HTTPS and receive the following error in the browser console:


Mixed Content: The page at 'https://[domain_name]/' was loaded over HTTPS, but requested an insecure resource 'http:// [domain_name]/api/'. This request has been blocked; the content must be served over HTTPS.


The page https://[domain_name]/api/ worked perfectly fine in the browser. One might think that the problem is in how the requests are redirected (for example in the NGINX configuration file). But the problem turned out to be in the Flask routing. I used @app.route("/api/", methods=["GET"]) instead of @app.route("/api", methods=["GET"]).

 

No comments:

Post a Comment