Open killswitch-GUI opened 3 years ago
Just got blocked by this same issue.
Getting this same error but not using StaticFiles.
I've solved this issue by using the app.mount
after the app = VersionedFastAPI(app)
And if you need to access the root path /
(for your landing page for example), define the @app.get
and its function after the app = VersionedFastAPI(app)
too.
@aminelemaizi thanks for the workaround! I would like to know if this is an acceptable way of doing this or if there needs to be a decorator to exclude mounts for a more official fix?
@killswitch-GUI , tbh I don't know if it is an acceptable way of doing things. I didn't see what does the code under the hood to confirm that.
Following.
Describe the bug Our team is struggling to get
fastapi-versioning
working in our environment since we are serving static assets for our frontend and docs. This seems to be an issue withmount
when usingStaticFiles
.To Reproduce Steps to reproduce the behavior:
app = FastAPI(title="My App")
@app.get("/") @version(1, 0) def greet_with_hello(): return "Hello"
@app.get("/") @version(1, 1) def greet_with_hi(): return "Hi"
app.mount("/", StaticFiles(directory="/"), name="static")
app = VersionedFastAPI(app)
Expected behavior A versioned API without having to version mounts.
Additional context N/A