我有一个 html 文件,我配置了链接的 URL,如下所示。
app.mount("/static", StaticFiles(directory="static"), name="static")
{{ url_for('static', path='css/style.css') }}
Run Code Online (Sandbox Code Playgroud)
我已经使用 nginx 和 haproxy 为应用程序创建了域。
加载 html 页面时,不会加载 css 和 js 样式,因为它使用的是 http 而不是 https。
Flask url_for 在 docker 运行时生成 http 而不是 https
Jinja2 模板中 url_for 创建的 FastAPI 链接使用 HTTP 而不是 HTTPS
我使用了一些关于类似问题的链接,但没有帮助,因为它是针对 html 文件的。
当我硬编码时它起作用了。我怎样才能使这个静态。我正在使用 uvicorn fastapi。