m1aw
m1aw
TTCTheo's Typesafe Cult
Created by m1aw on 9/19/2024 in #questions
Vercel deployment: [cause]: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON
I'm unsure where the error lies, but I'm getting [cause]: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON During deployments on Vercel. This happens during the Generate Static Asssets step.
Generating static pages (3/4)
getBaseUrl https://t3-personal-ghaf0nwa3-xxx-projects.vercel.app
<< query #1 entry.getAll {
Generating static pages (3/4)
getBaseUrl https://t3-personal-ghaf0nwa3-xxx-projects.vercel.app
<< query #1 entry.getAll {
I think this comes from:
function getBaseUrl() {
if (typeof window !== "undefined") return window.location.origin;
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`;
return `http://localhost:${process.env.PORT ?? 3000}`;
}
function getBaseUrl() {
if (typeof window !== "undefined") return window.location.origin;
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`;
return `http://localhost:${process.env.PORT ?? 3000}`;
}
This function getting VERCEL_URL while it's not available when making the tRPC call. I know because it's actually not hitting the tRPC backend and failing before that. What I don't understand is why is this not an issue for everyone?
12 replies