Skip to content

307 on a delete for a post request. #7706

Answered by vjpr
julian-r asked this question in Questions
Discussion options

You must be logged in to vote

Just had a look into this. The main FastAPI instance has an APIRouter.

When you create separate fastapi.routing.APIRouter instances and then use app.include_router(...), behind the scenes it is actually appending the routes from this router to FastAPI#router.

This should work:

app = FastAPI()
app.router.redirect_slashes = False

Seems that redirect_slashes means "redirect paths without trailing slash to slash", NOT "redirect trailing slash to no slash".

starlette/routing.py:601

        if scope["type"] == "http" and self.redirect_slashes:
            if not scope["path"].endswith("/"):
                redirect_scope = dict(scope)
                redirect_scope["path"] += "/"

Also, if y…

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@schang1146
Comment options

Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
7 participants
Converted from issue

This discussion was converted from issue #1208 on February 28, 2023 10:20.