[๐] SSG Link componet strips search parameters
handymenny opened this issue ยท 5 comments
Which component is affected?
Qwik City (routing)
Describe the bug
Since qwik 1.7.0, Link component strips search parameters.
For example:
Static adapter origin is http://localhost:9999
- I click a Link that should route to
http:/localhost:9999/view?id=42
-> it will route tohttp:/localhost:9999/view
- I click a Link that should route to
http:/127.0.0.1:9999/view?id=42
-> it will route tohttp:/127.0.0.1:9999/view?id=42
I would expect both links to route to [scheme]://[origin]:[port]/view?id=42
Reproduction
https://github.com/handymenny/qwik-ssg-link-bug/
Steps to reproduce
- Run:
npm ci npm run build npx serve dist -p 9999
- Open http://localhost:9999
- Click the two links
System Info
System:
OS: Windows 11 10.0.22631
Binaries:
Node: 20.15.1
npm: 10.2.5
Browsers:
Edge: Chromium (127.0.2651.74)
Additional Information
Versions affected:
- 1.7.0
- 1.7.1
- 1.7.2
- 1.7.3
Versions not affected:
- 1.6.0
- 1.5.x
- does also this happen with spa navigation?
- does the HTML contain the search string in the
<a>
tag?
- does the HTML contain the search string in the
<a>
tag?
Yes. This is the link that works:
<a href="http://127.0.0.1:9999/view/?id=42" q:key="AD_1">
<!--qv q:s q:sref=7 q:key=-->
http://127.0.0.1:9999/view/?id=42
<!--/qv-->
</a>`
This is the link not working:
<a q:link="" href="/view/?id=42" data-prefetch="" on:click="#0
q-DhbmnlE1.js#s_pIf0khHUxfY[0 1 1 1]" on:mouseover="q-DhbmnlE1.js#s_Osdg8FnYTw4" on:focus="q-DhbmnlE1.js#s_Osdg8FnYTw4" on:qvisible="q-DhbmnlE1.js#s_Osdg8FnYTw4" q:key="AD_1" q:id="9">
<!--qv q:s q:sref=8 q:key=-->
http://localhost:9999/view/?id=42
<!--/qv-->
</a>
- does also this happen with spa navigation?
I'm using Link, so it should already be SPA navigation, or am I wrong?
useNavigate()
has the same issue, raw html anchors don't have this issue.
One workaound I have found is to use a url that isn't exactly the right one as the origin of the static adapter.
For instance, http://abc.xy
vs https://abc.xy
.
The only side effect is that the canonical urls and the sitemap change.
Sorry I meant, does it work with regular SSR, not SSG?
Yes. I tried with nodejs adapter and it works.
This is the command I ran (powershell):
$env:ORIGIN='http://localhost:9999'; $env:PORT='9999'; npm run serve
This issue was fixed by #6778