Next.js Discord

Discord Forum

vercel blocking outbound fetch calls?

Answered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
    const isRequested = userRequested ? "?userRequested=true" : "";
    const url = process.env.NEXT_PUBLIC_HOST + PATH + isRequested;
    console.warn("### api URL", url);

    const response = await fetch(url, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        teamId: session?.user.currentTeamId,
        url: urlRecord.url,
        urlId: urlRecord.id,
        label: urlRecord.label,
      }),
    });
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }


this outbound call works on localhost but i get a 401 error on when i run it on dev.

Even if i write the hostname of my vercel preview deployment directly into the url
Answered by Cape lion
yes, this was resolved. Vercel Deployment Protection
View full answer

3 Replies

Cape lionOP
it gives a 401 error
Cape lionOP
yes, this was resolved. Vercel Deployment Protection
Answer
Cape lionOP
✅