Skip to content
Discussion options

You must be logged in to vote

You can probably do this with something like though I have not tested it

raise HTTPException(status_code=302, detail="Not authorized", headers = {"Location": "your/login/route"} )

Where the 302 tells the browser to redirect and the location header tells it where to redirect

These links might also help

https://fastapi.tiangolo.com/tutorial/handling-errors/#raise-an-httpexception-in-your-code

https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections

Replies: 1 comment 1 reply

Comment options

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

Answer selected by asaah18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants