-
First check
ExampleHere's a self-contained, minimal, reproducible, example with my use case: from fastapi import FastAPI, Request
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
app = FastAPI()
app.mount("/dist", StaticFiles(directory="views/dist"), name="static")
@app.get("/")
@app.get("/{pathname}")
async def render(pathname: Optional[str] = None, request: Request = None):
"A catch-all route"
await request.send_push_promise("/dist/manifest.webmanifest")
await request.send_push_promise("/dist/index.cbb1cf3e.css")
await request.send_push_promise("/dist/index.7553f2c4.js")
return FileResponse("views/dist/index.html")DescriptionAccording to Starlette docs, there is a Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
|
I believe http/2 has certain requirements, such as https? Have you tried over https? And how do you know they're not being sent over server push? |
Beta Was this translation helpful? Give feedback.
-
|
@Mause I'm testing the deployed app using this tool https://http2.pro/check, which tells me my server does support http2 but no resources are being pushed even though my main route is configured exactly like above. |
Beta Was this translation helpful? Give feedback.
-
|
you will need hypercorn , have you tried running with it? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
@v3ss0n I am in fact running hypercorn@0.10.2 but it's not pushing any resources according to Chrome (83) |
Beta Was this translation helpful? Give feedback.
-
|
Hey, I am having a similar problem. @adrian2x did you get it to work somehow? |
Beta Was this translation helpful? Give feedback.
-
|
@adrian2x, @rohanshiva - I have reached to this write up https://levelup.gitconnected.com/deploy-fastapi-with-hypercorn-http-2-asgi-8cfc304e9e7a?gi=74e947dae0af which may be useful if you miss configured the hypercorn instance |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the help here everyone! 👏 🙇 If that solves the original problem, then you can close this issue @adrian2x ✔️ |
Beta Was this translation helpful? Give feedback.
you will need hypercorn , have you tried running with it?
or http2 supported servers.