diff --git a/api/routes/security.py b/api/routes/security.py index 32b658c..b93f5db 100644 --- a/api/routes/security.py +++ b/api/routes/security.py @@ -332,13 +332,26 @@ async def redirect_callback(code: str, state: Optional[str] = None): # samesite="lax", # ) # else: - response.set_cookie( - access_token_key, - f"Bearer {access_token}", - domain=domain, - httponly=True, - samesite="lax", - ) + + if "localhost" in redirect_domain: + # Adjust host header to localhost + response.headers["host"] = redirect_domain + response.set_cookie( + access_token_key, + f"Bearer {access_token}", + domain="localhost", + httponly=True, + samesite="lax", + ) + + else: + response.set_cookie( + access_token_key, + f"Bearer {access_token}", + domain=domain, + httponly=True, + samesite="lax", + ) return response