In FASTAPI, does RedirectResponse not change the url on the current page?

Viewed 39

Below is my code.

@app.post("/")
async def main(user: schemas.UserCreate, db: Session = Depends(get_db)):
    db_user = crud.get_user_by_email(db, email=user.email)
    if db_user:
        return RedirectResponse(url = '/exist',status_code=302)
    crud.create_user(db=db,user=user)
    return RedirectResponse(url='/', status_code=302)


@app.get('/exist')
async def exist():
    return {'message' : "already exist"}

I check network and the Redirect Response itself works fine. enter image description here However, the url on the page remains the same as the current page.

I want to change url to "/exist", How can I do this?

0 Answers
Related