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

QueryParams are stripped #4399

Closed
1 task
pbrissaud opened this issue Aug 20, 2022 · 6 comments
Closed
1 task

QueryParams are stripped #4399

pbrissaud opened this issue Aug 20, 2022 · 6 comments

Comments

@pbrissaud
Copy link

What version of astro are you using?

1.0.6

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

Linux

Describe the Bug

When navigate to a page with querystring params, the Astro.url strip params and Astro.url.search and Astro.url.searchParams are empty.

Did I misunderstand something or is it a bug ?

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-nxwxap

Participation

  • I am willing to submit a pull request for this issue.
@FredKSchott
Copy link
Member

This is expected, because Astro builds a static site by default your build does not have access to search params. Only a server can see the search params, since they are passed by the user when the user makes a request, and static sites are built ahead of time without knowing what search params a user might send.

If you change output: 'server' in your config, Astro will stop stripping those values. Learn more: https://docs.astro.build/en/guides/server-side-rendering/

@pbrissaud
Copy link
Author

Thanks @FredKSchott for your answer !

I resolved my problem by using a Vue component that can use window.location.href function to get params.

@FredKSchott
Copy link
Member

sounds perfect!

@vic-cekvenich
Copy link

"Astro builds a static site by default your build does not have access to search params." This is a bug.
That is not how http server(Apache, NGNIX) work, nor other static generators (eg 11ty). Search params are a browser command, so Astro removing it when it is client side is bug. I should not have to use server side just for querystring.

Re-opened: #7489

@BigWillie
Copy link

I don't appear to be able to query the params from the server side either.

@HananoshikaYomaru
Copy link

if I set the config output to be hybrid and set the prerender of the page to be false, still the query params are stripped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants