Open riencoertjens opened 1 year ago
It's by design that useServerData
only works in server, in fact I would say, it's a very low level API, that most developers should never have to use. Ie, if you have to use it... something else might be wrong with qwik.
How to manage nonce then? I did it according to this example, https://qwik.dev/docs/advanced/content-security-policy/. There's a script that is loaded dynamically (google auth). const nonce = useServerData<string | undefined>('nonce')
is undefined there. By dynamic I mean a user clicks on a button, and then a client component is being loaded. It loads an external script with nonce.
for now, in the ssr.entry you can add it as a prop to Root then query for that value
Which component is affected?
Qwik Runtime
Describe the bug
useServerData(key)
doesn't return the data after a qwik-city navigation, both in dev and previewReproduction
https://github.com/riencoertjens/qwik-redirect-issue-reproduction/tree/server-data-issue
Steps to reproduce
go to /serverdata using <Link href="/serverdata"/>
or buttonexpectation: shows serverData added in entry.ssr.ts
what happens: no data is shown
it does work on initial load or when using an
<a />
to do the navigation,System Info
Additional Information
No response