You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When adding a toast and then redirecting to a new route (either through RedirectResponse or HttpHeader('HX-Redirect') it doesn't show up after the redirect. The session is empty after the redirect (at least the key for the toasts).
Minimal Reproducible Example
fromfasthtml.commonimport*app, rt=fast_app(live=True, debug=True)
setup_toasts(app)
@rt('/')defget():
returnDiv(
H1('Hello, World!'),
P('This is a simple example of a FastAPI app using FastHTML.'),
Form(
Input(
type='text',
placeholder='Enter your name',
name='name',
),
Button('Submit', type='submit'),
method='post',
action='/result',
),
cls='container',
style='max-width: 680px',
)
@rt('/result')defpost(name: str, session):
add_toast(session, f'Hello, {name}!')
print(session)
returnRedirectResponse('/result', status_code=303)
@rt('/result')defget(_, session):
print("session after redirect: ", session)
returnDiv(
H1('Hello, World!'),
P('This is a simple example of a FastAPI app using FastHTML.'),
cls='container',
style='max-width: 680px',
)
serve()
Expected behavior
I would expect the toasts to show up, even after redirecting. A possible scenario in a real-life app would be to show the user that they are now logged in.
Environment Information
Please provide the following version information:
Describe the bug
When adding a toast and then redirecting to a new route (either through
RedirectResponse
orHttpHeader('HX-Redirect')
it doesn't show up after the redirect. The session is empty after the redirect (at least the key for the toasts).Minimal Reproducible Example
Expected behavior
I would expect the toasts to show up, even after redirecting. A possible scenario in a real-life app would be to show the user that they are now logged in.
Environment Information
Please provide the following version information:
Confirmation
Please confirm the following:
Additional context
Add any other context about the problem here.
Screenshots
If applicable, add screenshots to help explain your problem.
The text was updated successfully, but these errors were encountered: