#Router URL does not change when compiled as SSG

36 messages ยท Page 1 of 1 (latest)

viral escarp
#

Hey everyone! Happy to be here, thanks for the awesome experience Qwik provides. I'm currently learning a lot about the framework and used my personal "blog" (more like a test environment) for the first steps.

I've got a question: When I add the qwik add "Static Site" package and compile it, it successfully puts everything into the "/dist" folder. I can run this stuff for example with the npmjs "http-server" package and it works. However, when I change routes, it does not apply the path to the URL. Is it intended and what can I do, so that it updates the URL? You can have a look at the behavior at felixlemke.dev (as mentioned, it's my testing project). That's the hosted output of the "/dist" folder on Vercel and behaves exactly the same as running the app with the "http-server" package.

My expectation would be that when I click for example on "Blog" the URL changes to felixlemke.dev/blog, however it remains felixlemke.dev.

Any help would be very much appreciated. Thanks a lot in advance!

keen cobalt
#

@viral escarp Hello Felix! How are you navigating? Is it a simple anchor link or do u navigate on click with the use of useNavigate()?

hallow escarp
#

This just started happening to me. I updated my Qwik city version to use the new server$ function and it was working fine in development but after building and deploying to production the URL does not update. This is happening on both chrome and safari. I am using useNavigate and Link.

Example: https://staging-app.luxfinancial.io

#

I noticed the useNavigate API changed when I updated Qwik City. Did something break?

#

You used to change routes like this.

useNavigate().nav = '/new-route'
#

Now nav is a function that takes a route param

viral escarp
#

Thank you for your answer ๐Ÿ™‚ I only use the Link component exported by "@builder.io/qwik-city".

#

Like

<Link href={menuItem.href}>...</Link>
<Link href="/about">...</Link>

and so on.

dusk edge
#

@viral escarp That Link component uses the useNavigation method

hallow escarp
#

So is this an issue with Qwik City 0.4.0?

viral escarp
#

Currently I use 0.19.2 for qwik, and 0.4.0 for qwik-city. But it existed also in 0.18.1 and 0.2.1. This was the main reason why I performed the update.

#

And when using the default dev server with "npm run dev" running "vite --mode ssr" it works as expected.

#

And when I disable JavaScript it also works as expected for the SSG output

hallow escarp
#

Is there an open issue for this

viral escarp
#

I haven't created one, yet. May I?

hallow escarp
#

I think there should be one. This seems to be an issue

viral escarp
hallow escarp
#

Is there a workaround for this? I need the server$ function which is why I upgraded to 0.4.0 but I also need it to work in production ๐Ÿ˜ญ

viral escarp
#

Haven't found any workaround, yet.

#

It seems to be related to line 18 in the client-navigate.ts file, where it's using

// push the new route path to the history
win.history.pushState('', '', toPath(newUrl));

For some reason, this line does not execute in SSG.

viral escarp
viral escarp
#

Is it possible that the compiler tree-shakes the clientNavigate function completely?

hallow escarp
#

I don't know. I tried updating qwik-city to v0.5.2 and still having the same issue. I might have to rollback to v0.0.128

keen cobalt
hallow escarp
#

I'll try that

keen cobalt
# hallow escarp I'll try that

I wait with minor version updates for at least a week, so these things get fixed. It saves me from headaches ๐Ÿ˜„ . This version seems stable enough for me

"@builder.io/qwik": "0.18.1",
"@builder.io/qwik-city": "0.2.1",
hallow escarp
#

Good call

hallow escarp
#

Well that didn't work. I ended up rolling back to v0.0.128. I had to refactor everything that used useLocation and useNavigate. It is working again ๐Ÿฅฒ

keen cobalt
hallow escarp
#

It was working but it just would not update the URL in the browser.

#

With the old api useNavigate().path = '/settings'

#

This works

keen cobalt
hallow escarp
#

Flippin weird

#

Kind of a bummer but everything is working now. I guess I just need to stay on v0.0.128 for now

viral escarp
#

Versions 0.18.1 and 0.2.1 (city) do not work for me, for both my project and also the reproduction repo for the github issue.