-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Failed to parse URL from /api/images #66330
Comments
Hi,
You are setting yourself up for errors and problems, read more here: https://nextjs-faq.com/fetch-api-in-rsc |
So what will be the soluton?
|
Isn't there like a HydrationBoundary component in that package? Get the data you need, directly from source, and pass it to the hydration boundary as shown, then consume it with the hooks the package provides. I think you are fundamentally misunderstanding something here. As you point out, in the vanilla case, there cannot be anyone handling the api request during build time, because the server is being built at that time as well. Locally, the fetch cache is tricking you, because it stores the development time result. Try removing .next and rebuilding locally, it'll fail too. What's more, within a server side context, how can fetch know, relative to what to make the request. In the browser it can make some assumptions about the baseURL, from some document properties, but on the server, at the end of the day, it is just a Node.js script running. Alternatively, you could disable the query on SSR? but that's like, not good... it has been some months since I used that package too, so I am a bit rusty, but reading the docs, it does sound like they accommodate this use case very well |
Yeah, as I posted the example above: #66330 (comment) , it shows error on both environment. You can check the code that I shared on stackblitz What I want to know is the solution for this problem. Is this issue related to react query? Thanks |
The solution is on the docs for that package |
Sounds good. |
Then this won't be a problem. The callback of useEffect is not run during SSR, only on the client. |
Closing this as guidance has been provided above to use the absolute URL versus the relative URL when making a |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://stackblitz.com/edit/stackblitz-starters-qyc8rc?file=README.md
To Reproduce
Current vs. Expected behavior
Current:
Throws error:
TypeError: Failed to parse URL from /api/images
Expected:
Should build successfully
Provide environment information
The text was updated successfully, but these errors were encountered: