url_for is using HTTP instead of HTTPS in FastAPI

Viewed 70

I have a html file and I configured the URL of the links as below.

app.mount("/static", StaticFiles(directory="static"), name="static")

{{ url_for('static', path='css/style.css') }}

I have got the domain creation for the application with nginx and haproxy.

When the html page is loaded the css and js stylings are not being loaded as it is using http instead of https.

Flask url_for generates http instead of https when running by docker

FastAPI links created by url_for in Jinja2 template use HTTP instead of HTTPS

I went with some of the links on similar issue but didn't help as it is for html files.

When I hardcoded it worked. How can I make this static. I am using the uvicorn fastapi.

0 Answers
Related