Next.js Discord

Discord Forum

Failed to parse URL from server component to own localhost API

Answered
New Guinea Singing Dog posted this in #help-forum
Open in Discord
New Guinea Singing DogOP
Hey there, for some reason I'm able to get data on the client side fine, but cannot call it on the server side, even when using the absolute URL.

10 Replies

New Guinea Singing DogOP
"Failed to parse URL from /api/getUser"
@New Guinea Singing Dog "Failed to parse URL from /api/getUser"
iirc you need to add full url server side to fetch
New Guinea Singing DogOP
    let res = await fetch('http://localhost:3000/api/getUser', {
        method: "POST", body: JSON.stringify({
            userID
        })
    })


yes that's what im using the full url
with the protocol and domain
it works in node weirdly
But i dont think it should be effected by same origin policy because i didnt think that involved POST-type requests
Answer
New Guinea Singing DogOP
tysm
oh yeah that looks like it