Document in the InertiaJS the importance of avoid to use "no-referrer" as meta "referrer" parameter #477
Replies: 5 comments 12 replies
-
From what I can tell, Laravel already handles this the way it's supposed to. The base FormRequest validation calls Maybe there's a bit more at play with Inertia, but it looks like Laravel always uses a fallback to the previous URL that's stored in the session when no referrer is present. |
Beta Was this translation helpful? Give feedback.
-
Note: It is not an InertiaJS bug, it's how Laravel works, so this is the reason by I think that is important to add a mention in the documentation about the "no-referrer" policy. |
Beta Was this translation helpful? Give feedback.
-
I've stumbled across this thread because it's the only thing that comes close to a similar issue I'm having which is Inertia specifying the wrong Referer header but only on my production sites. Locally referer is set correctly and this is the case even if using exactly the same built production-ready file (assets are compiled and put into version control). If I have no referer meta set in the HTML layout, the form will, no matter what the scenario redirect back to the root. If the meta no-referrer policy is set, the referer header specified is whatever page I hit first. Navigating using an Inertia Link to a second page and using a form there will force a redirect to the first page I visited (if the result of that request on Laravel is a redirect back to the previous page for example). This is happening because if Laravel doesn't see a referer header, it will use the last known page to redirect back to which in this scenario is the first page I hard visit. Subsequent Inertia requests do not register on Laravel as URL visits. Absolutely no idea why this is happening as I can't understand if it's an Inertia specific thing I need to dive further into, an Axios specific thing, a HTTP thing etc. Any pointers would be great! |
Beta Was this translation helpful? Give feedback.
-
Not the same issue at all but I had a somewhat similar thing with the session flash data not persisting between redirects. |
Beta Was this translation helpful? Give feedback.
-
I have a very similar issue than @juanparati.
The problem is that the previous URL from the session is not the URL who sent the POST request (aka the login page). On my local server, the referer is well defined and I am redirected to the login page with the errors displayed. What can we do to fix this (except add the referer in the headers) ? Thank you! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel detects the last visited page reading the "referrer" header for GET requests.
I observed that Laravel redirect to the previous page when meta "referrer" parameter is equal to "no-referrer" and a form is posted without pass the validation. This is an issue because the user maybe redirected to different page without receive the validation error message.
I propose to add in the links page (https://inertiajs.com/links) a mention about that post requests may redirect to a wrong page when validation fails when meta "referrer" is equal to "no-referrer".
Note: This is not an InertiaJS issue but the default Laravel behavior.
Beta Was this translation helpful? Give feedback.
All reactions