How can I post/redirect/get?
@app.post("/")
async def login():
return RedirectResponse(url="/ressource/1")
@app.get("/ressource/{r_id}")
async def get_ressource(r_id: UUID):
return {"r_id": r_id}
I found the way to do this. You need to change the redirect default code 307 to 302.
...
return RedirectResponse(url="/ressource/1", status_code=HTTP_302_FOUND)
...
Thanks for reporting back and closing the issue :+1:
You can also use 303 (HTTP_303_SEE_OTHER) which was designed to handle redirects after a POST request. It's also mentioned on wiki for PRG pattern https://en.wikipedia.org/wiki/Post/Redirect/Get
Most helpful comment
I found the way to do this. You need to change the redirect default code 307 to 302.