FastAPI (gunicorn) bị lỗi Mixed Content HTTPS vs HTTP

Table of Contents

FastAPI (gunicorn) bị lỗi Mixed Content HTTPS vs HTTP

Nhận dạng lỗi

Mixed Content: The page at 'https://aaaa' was loaded over HTTPS, but requested an insecure stylesheet 'http://aaaa/static/dist/css/bootstrap.min.css'. This request has been blocked; the content must be served over HTTPS.

image

Cách sửa FastAPI (gunicorn) bị lỗi Mixed Content HTTPS vs HTTP

Bổ sung thẻ <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> vào file template html của bạn


Another workaround is to add:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

to index.html file in frontend. It will upgrade all requests from http to https (also when run locally, so it may not be the best workaround)

Tham khảo

  1. https://stackoverflow.com/questions/63511413/fastapi-redirection-for-trailing-slash-returns-non-ssl-link

Leave a Reply

Your email address will not be published. Required fields are marked *