I get The page at 'https://example.com/login/' was loaded over HTTPS, but requested an insecure stylesheet 'http://example.com/index.css/'. This request has been blocked; the content must be served over HTTPS. when attempting to load my index.css file. This was working 3 days ago but recently stopped. This is resulting in a non-styled page for the end user. I am using flask for my web server. empty login page
I originally had my css file loaded as /index.css, but when that stopped working, I tried manually stating https:// in my stylesheet link. My current html for the stylesheet is <link rel="stylesheet" href="https://example.com/index.css"> Code from site:
I’d be glad to help you fix the mixed content issue in your Flask application’s login page. Here’s the consolidated solution:
1. Ensure Your CSS File is Accessible over HTTPS:
Verify that index.css is located in a directory accessible by your Flask app when running. This could be a static directory within your project structure.
If the file is on a separate server, configure it to be served over HTTPS as well.
2. Update Your HTML Link with the Correct Path:
Use a relative path assuming index.css is in the same directory as your HTML file:
HTML
<link rel="stylesheet" href="index.css">
If it’s in a static directory named static, use a relative path within the template:
3. Flask Configuration (Optional but Recommended):
If you have a dedicated static directory in your Flask project, configure it in the Flask app’s settings:
Python
If you’re using a web server like Apache or Nginx in front of Flask, ensure it’s configured to serve static files correctly. This might involve setting up directory listings or access permissions.
Complete Example with Flask Static Files:
Assuming your CSS file is in a static directory within your Flask project, here’s a sample layout: