fix!: handle non-inertia location
redirects
#312
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sometimes, we want to perform an external redirect that can be initiated on the first visit or on an Inertia visit.
In such a case, Inertia's
location
won't work because it will only simply return a normal409
response with theX-Inertia-Location
, but since the front-end is not loaded the end result will be a blank page.To fix this, we need to check if the current request is an Inertia one, perform the
location
redirect, or return a classicRedirectResponse
otherwise.This PR fixes that issue by performing that check internally so the developer doesn't have to.
This is technically a breaking change since I had to modify the original test, but it's a breaking change that is more likely to fix issues than to create some.
TL;DR: with this PR, instead of doing:
We can just do:
Fixes #295