[Python] How to redirect from one domain to another and set cookies or headers for the other...

Discussão em 'Python' iniciado por Stack, Janeiro 25, 2025.

  1. Stack

    Stack Membro Participativo

    I am using FastAPI's RedirectResponse and trying to redirect the user from one application (domain) to another with some cookie set in the Response; however, the cookie always gets deleted (not transferred). If I try to add some headers, all the headers that I add to RedirectResponse are not transferred either.

    @router.post("/callback")
    async def sso_callback(request: Request):
    jwt_token = generate_token(request)
    redirect_response = RedirectResponse(url="http://192.168.10.1/app/callback",
    status_code=303)
    redirect_response.set_cookie(key="accessToken", value=jwt_token, httponly=True)
    redirect_response.headers["Authorization"] = str(jwt_token)
    return redirect_response


    How can I solve this? Thanks in advance for the help.

    Continue reading...

Compartilhe esta Página