-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
URL used in Response class does not respect HTTP_X_FORWARDED_PREFIX header #236
Comments
This does not seem to be an inertia issue. Assuming you are using laravel (hence this repo) have you set, have you configured the |
Thanks @herpaderpaldent for your quick reply. Sorry yes this is in a Laravel project and yes I have already configured to TrustProxies so URL generation is working correctly. Redirects work correctly but when I hit a page managed by Inertia it then updates the pushState in the browser to the URL sent in the Response payload. So the page at first works correctly but if the user refreshes the page it is now on the wrong page. The issue is that Inertia is not using the same functions as Laravel for generating the URL in the response. By using the getRequestUri() method it only returns the path and not the fully formed URL using the HTTP_X_FORWARDED_PREFIX header. My suggestion is that by changing that to use the fullUrl() method it would include it and from some initial testing appears to fix the problem. However I think that will return the domain as well as the path so not sure if that would cause any other issues? |
Hello, I seem to have the same problem. I've setup a reverse proxy to redirect to a specific subpath of the laravel application. Then the js frontend updates the browser history to include the full path. Not sure if I am missing a header that needs to be passed to laravel for this to work? |
@lmjhs I had a same problem. Do you have a elegant solution for this? |
I believe this was solved in #333, although that potentially introduced another bug (#359). Note that in addition to configuring the trusted proxy, the protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
+ Request::HEADER_X_FORWARDED_PREFIX |
Request::HEADER_X_FORWARDED_AWS_ELB; |
When using a reverse proxy to remove the path prefix from a URL, the url property sent with the inertia response does not respect the HTTP_X_FORWARDED_PREFIX header. This causes the browser history pushState to be rewritten to the wrong URL.
For example:
Changing
'url' => $request->getRequestUri()
to'url' => $request->fullUrl()
inInertia\Response
seems to solve the problem as this will create a full url including the HTTP_X_FORWARDED_PREFIX header.However there may be a more elegant solution?
The text was updated successfully, but these errors were encountered: