DeanWay / fastapi-versioning

api versioning for fastapi web applications
MIT License
642 stars 63 forks source link

Versioning not applied to RedirectResponse #61

Open JorenVanSeveren-IPG opened 2 years ago

JorenVanSeveren-IPG commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

When redirecting from a versioned route to another I'd expect the same version to be prefixed, but that's not happening. As a fallback I'd expect a way to fetch the current version, but there seems to be no easy way to do that (I guess I can fetch it from current path, but doesn't seem clean).

To Reproduce Steps to reproduce the behavior:


@version(1, 0)
@app.post("/original_route")
async def original_route():

    return "test"

@version(1, 0)
@app.post("/route_alias")
async def redirect_search_ads():

    return RedirectResponse(
        '/original_route', 
        status_code=status.HTTP_302_FOUND)

app = VersionedFastAPI(app,
    version_format='{major}.{minor}',
    prefix_format='/v{major}.{minor}')

Expected behavior Redirect from /v1.0/route_alias to /v1.0/original_route instead of to /original_route