Replies: 1 comment
-
Hi, I had the same issue and de-duplicated the requests by specifying the From https://nuxt.com/docs/api/composables/use-fetch:
You can then write something like this: let {data, error} = await useFetch(backend_host + path, {
key: path,
...
}) Maybe you should consider adding more information like request parameters in the key to prevent too much de-duplication issues, see #21532 for an example and a related issue it could lead to. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Nuxt Community!
My goal is to pass different domains to useFetch() for the server and the client calls, without Nuxt Server API Endpoints. For example the client URL starts with
public domain over https
, while the server URL starts withlocalhost over http
.I was not able to reproduce exact scenario on stackblitz but the result is the same because URLs for the server and for the client are different https://stackblitz.com/edit/github-drhg3c?file=app.vue
On the server side the behaviour is as expected. But on client side, the behaviour is suprising:
Network:
Console:
The client (browser) fetches data, it takes 51 ms but
useFetch()
returnsnull
after just 2 ms (trying to use cached data from server, but URL is different?) and the real client's response seems not to be used at all. Finally nuxt returns hydration mismatch warning because the data on the client side is null .Is
useFetch()
designed to support described case?P.S If SSR is disabled averything looks fine:
Console:
Beta Was this translation helpful? Give feedback.
All reactions