Closed finestgecko closed 2 years ago
I had some problems using inertia.location(...) in my application.
inertia.location(...)
According to the Inertia docs, the server should send a 409 Conflict response, with the destination in the X-Inertia-Location header.
409 Conflict
X-Inertia-Location
Looking at the request, it does indeed do this. However, there are two Inertia headers:
x-inertia true x-inertia-location http://<redacted>/auth/login
I asked for help in the Discord channel for Inertia and it was pointed out to me that:
According to the protocol, there should only be an X-Inertia-Location header - X-Inertia should not be present for a redirect to happen.
X-Inertia
The presence of X-Inertia causes setPage() to be called in Inertia (see here).
setPage()
So, instead of using inertia.location(), I set the headers manually:
inertia.location()
response.header('X-Inertia-Location', <some url>) response.removeHeader('X-Inertia') // 👈 removing X-Inertia return response.conflict()
... and it works perfectly.
Also, on a side note, using inertia.location() causes a TypeScript error:
Property 'location' does not exist on type 'InertiaContract'.
Hey @joelcieslar ! Thank you reporting this and for going the extra mile with the details. It's been fixed in v6.2.1.
v6.2.1
Feel free to reopen if you run into additional issues.
I had some problems using
inertia.location(...)
in my application.According to the Inertia docs, the server should send a
409 Conflict
response, with the destination in theX-Inertia-Location
header.Looking at the request, it does indeed do this. However, there are two Inertia headers:
I asked for help in the Discord channel for Inertia and it was pointed out to me that:
According to the protocol, there should only be an
X-Inertia-Location
header -X-Inertia
should not be present for a redirect to happen.The presence of
X-Inertia
causessetPage()
to be called in Inertia (see here).So, instead of using
inertia.location()
, I set the headers manually:... and it works perfectly.
Also, on a side note, using
inertia.location()
causes a TypeScript error: