Error on adding t3 app router to existing NextJS project
Hi, so i've init'ed the new t3app router template, and tried to transition it to an existing project. I can get Client-side tRPC calls to work, but Server-side tRPC calls give this error:
I can't seem to wrap my head around what the error is about...
Will add to this post as i figure it out.
30 Replies
Here's the branch link. https://github.com/embersee/delphox/tree/add-t3-principles
thanks for helping out ^^
GitHub
GitHub - embersee/delphox at add-t3-principles
Contribute to embersee/delphox development by creating an account on GitHub.
The error has got to do with environment variables in a .env file... what a turn of events. When i add my own variables the server gives out the previous error. If the .env file is untouched from t3@latest generated template – everything works fine.
Anybody any idea what that could be?
Well this is fixed. The error was an environment variable that just broke everything... Do not use VERCEL_URL in your .env or env.mjs files
hi, im also facing similar issue...
im using sst to deploy, i'm guessing its the getBaseUrl in shared.ts?
i still cant figure out why on my side...
Ya I had the same issue, if u add the VERCEL_URL to your .env and env.mjs, the trpc/shared.ts will use that as the url for local development. Instead, add the VERCEL_URL in your env vars in Vercel
im using sst tho
did u remove the vercel_url env from .env?
yup
got a repo to share? i can have a look
1 min!
GitHub
GitHub - Hyperfuse-Studio/base-code-t3-prisma
Contribute to Hyperfuse-Studio/base-code-t3-prisma development by creating an account on GitHub.
i can see this
is this erroring in prod on sst or local?
prod
working locally
Create T3 App
Generated by create-t3-app
id suggest replacing this func:
replace with:
did you change yours too?
And add a SST_URL into .env
vercel_url is a reserved env name im assuming, hence the crashing
hmm let me try that
also like ur SST_URL should be the URL that it deploys to, like https://d1mzwcg7pl8jm9.cloudfront.net/ this one you send earlier. Maybe you already know this ^^
Create T3 App
Generated by create-t3-app
But, the SST_URL env should only be available on your deployment, not locally ... hope that makes sense
yup, got it. lemme try that
doesnt seem to make any diff 😦
Funny thing today I tried with vercel to deploy it’s also not working 🤣
sorry i dont know how much more i can help :((
No worries! Trying to dig around to test more 🫠
are u trying to transition an app to ct3a or just starting a fresh one?
Fresh one
probably make an issue in the repo, think there's gonna be people who will see it
I mean if the fresh one can’t even work properly after deploying to sst, then I wouldn’t even use it 🤣
Yeah will try out few more times before seeking for help 👍🏻
I have the exact same, have you figuered out what was the problem?
Omg you are a life saver!
you’re welcome 😊
I faced the same issue but i dont have VERCEL_URL in my .env file 😢