Closed pbrissaud closed 2 years ago
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/
Thanks @FredKSchott for your answer !
I resolved my problem by using a Vue component that can use window.location.href
function to get params.
sounds perfect!
"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.
I don't appear to be able to query the params from the server side either.
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.
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 andAstro.url.search
andAstro.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