May I have an option to set cookie before redirect response? I face an issue that cookie is loaded only after I manually refresh page
async def render_authenticated_response(
request: Request, authentication_info: dict[Any, Any], jwt_token: str
) -> HTTPResponse:
"""Render response after authentication"""
response = redirect("/")
set_cookie(
response=response,
domain="127.0.0.1",
key="jwt_token",
value=jwt_token,
httponly=True,
samesite="strict",
secure=True,
expires=authentication_info["expires_at"],
)
return response
Can Sanic make something similar to make_response() Flask function to set up cookie before response? Flask example:
@app.route('/')
def index():
resp = make_response(render_template(...))
resp.set_cookie('somecookiename', 'I am cookie')
return resp