Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LiveComponent] Response 400 after application idle for long time #2278

Closed
tito10047 opened this issue Oct 17, 2024 · 4 comments
Closed

[LiveComponent] Response 400 after application idle for long time #2278

tito10047 opened this issue Oct 17, 2024 · 4 comments

Comments

@tito10047
Copy link

Hi,
I have Aplication with live component which is opened in background for long time (one day).
When I wake up mornig, and do interaction with application with live component, I get Status code from server "400 Bad Request" . This is happening every morning.
Actualy is is error "Invalid CSRF token." but its show 400 and popup big screen error.

How I can suppress or catch this error and reload page?

Thanks

@smnandre
Copy link
Member

Naive question, but do you need crsf protection ?

@tito10047
Copy link
Author

Yes, in current project I can disable crsf. But this will be happening in all my projects.
So, question is still justified. How I can catch error page and show my own error? like "your session is expired, please reload page"

@smnandre
Copy link
Member

There is an event you can hook yourself on:

response:error args (backendResponse: BackendResponse, controls: { displayError: boolean })

https://symfony.com/bundles/ux-live-component/current/index.html#javascript-component-hooks

There is also a PR in progress to improve this modal and display custom attribute / content if you want to have a look

@tito10047
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants