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

Use fresh routes from HandleInertiaRequest #698

Closed
wants to merge 5 commits into from

Conversation

guilheb
Copy link

@guilheb guilheb commented Dec 22, 2023

As discussed in #696, it would be really nice for the route() function to always have up-to-date routes.

The simplest use-case is having a small set of routes for the whole world to see (login, registration, etc) and then have access to all routes once a user is logged in. This is easily achievable in HandleInertiaRequest, but the JavaScript object is never updated. This PR ensure the route() function uses the fresh list of routes.

@bakerkretzmar
Copy link
Collaborator

Thanks for the PR 👍🏻 Ziggy can't call usePage() internally because it's not just used in Inertia apps. The best way to make sure all routes are always available is to use the @routes Blade directive. If you don't want to do that the simplest alternative is overriding the route function in your own app, like you did.

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

Successfully merging this pull request may close these issues.

2 participants