Skip to content
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

Query params are stripped after GET request #912

Closed
burlesona opened this issue Sep 23, 2021 · 3 comments
Closed

Query params are stripped after GET request #912

burlesona opened this issue Sep 23, 2021 · 3 comments
Assignees
Labels
svelte Related to the svelte adapter

Comments

@burlesona
Copy link

Versions:

  • "@inertiajs/inertia": "^0.10.1",
  • "@inertiajs/inertia-svelte": "^0.7.4",

Describe the problem:

After following an inertia link with query params, the query params are not present in the browser's URL. Interestingly, they are passed to the server, so the request "works," but if the user refreshes on the page the params are lost.

I would expect the query params to stay present in the browser's URL.

Steps to reproduce:

Create a link with query params and click it. Here are the examples I tried, all of which have the same behavior of not passing the query params into the browser's URL (even though they do make the GET request using the params):

<a use:inertia href="/test?param1=true&param2=false">Test</a>
<Link href="/test?param1=true&param2=false">Test</Link>

From the docs I wondered if using the data option would be better than passing the full URL string, but when I tested using the data option the params were not passed at all.

@burlesona burlesona added the svelte Related to the svelte adapter label Sep 23, 2021
@burlesona
Copy link
Author

@reinink would it be possible for you to confirm whether this is the expected behavior? Ie. if I enter the following URL in an Inertia app and hit enter:

https://myapp.com/test?a=1&b=2

...would you expect the query params to be removed from the URL after the Inertia app inits, or to remain in the URL?

I originally though this was something specific to the Inertia Link component, but it's actually independent of that. The query params disappear after the page finishes executing JS even when you manually put them into the URL and cause a full page load.

@claudiodekker claudiodekker moved this to Todo in Inertia.js Oct 7, 2021
Repository owner moved this from Not Started 🕑 to Complete ✅ in Inertia.js Dec 6, 2021
@burlesona
Copy link
Author

For future reference in case this helps anyone else: I eventually figured this one out, the query params were actually missing on the url param in the props sent from the backend to the frontend. I find it a little surprising that the client reads from this param rather than from window.location, but once I realized that issue it was an easy fix.

@claudiodekker claudiodekker moved this from Done ✅ to Archived 📦 in Inertia.js Jan 4, 2022
@mgkimsal
Copy link

mgkimsal commented Mar 6, 2023

For future reference in case this helps anyone else: I eventually figured this one out, the query params were actually missing on the url param in the props sent from the backend to the frontend. I find it a little surprising that the client reads from this param rather than from window.location, but once I realized that issue it was an easy fix.

I realize it's been a while, but I'm hitting this. What was the 'fix'? (TIA)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
svelte Related to the svelte adapter
Projects
Archived in project
Development

No branches or pull requests

3 participants