Skip to content

Can't use fetch() when using SSR #12064

Answered by eltigerchino
Oreeeee asked this question in Q&A
Discussion options

You must be logged in to vote

3.289 [cause]: TypeError [ERR_INVALID_URL]: Invalid URL

I'm assuming the error is due to the use of the Node.js fetch (server-side fetch) with a relative URL ("/data/started-time"?). Only browsers can make relative URL fetch requests. On the server, it must be an absolute URL (e.g., http://localhost:8000/data/started-time).

Instead, you should fetch the data inside a SvelteKit load function. Read more:

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Oreeeee
Comment options

Answer selected by eltigerchino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants