Redirects
When making a non-GET Inertia request, via <inertia-link>
or manually, be sure to always respond with a proper Inertia response.
For example, if you're creating a new user, have your "store" endpoint return a redirect back to a standard GET endpoint, such as your user index page.
Inertia will automatically follow this redirect and update the page accordingly. Here's a simplified example.
External redirects
Sometimes it's necessary to:
redirect to an external website
or even another non-Inertia endpoint in your app, within an Inertia request.
This is possible using a server-side initiated window.location
visit
This will generate a 409 Conflict
response, which includes the destination URL in the X-Inertia-Location
header. Client-side, Inertia will detect this response and automatically do a window.location = url
visit.
Last updated