UPLOADTHING_URL is still set to localhost:3000
I have my app on vercer server and I'm still getting this error:
Access to fetch at 'http://localhost:3000/api/uploadthing' from origin 'https://thymotion.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
even when I set the UPLOADTHING_URL
the error is the same...
What should I do?12 Replies
#uploadthing can get your a faster answer
thanks
UPDATE: just tested the v4.0.0 and everything works well...
So it seems that there is some error with v4.1.0+
Hmmm, are you deploying on Vercel, or somewhere else?
I am not seeing any changes between 4.0.0 and 4.1.0 that should have any effect on this 🤔
Something isn't right here. It looks like your prod instance is trying to ping localhost which doesn't make sense. Is the repo public? What is the value of
UPLOADTHING_URL
sory the repo is private, but here are my findings:
I have a Vercel instance with UPLOADTHING_URL=https://thymotion.com/
when I have 4.1.0 or 4.1.1 the uploadthing is pinging the localhost:300
when I downgrade to 4.0.0 the url is https://thymotion.com/
My suspicion is that something happened in this PR https://github.com/pingdotgg/uploadthing/pull/122
@marminge ☝️ but I don't wan to point fingers at anybody! 🙂
this is what we're pinging: https://github.com/pingdotgg/uploadthing/blob/8e04d9782b194feea74fd6abc2312bd105ae0f5d/packages/uploadthing/src/utils.ts#L163
what's different is that when prefetching on the server, the url must be absolute. from the clietn the url is relative
GitHub
uploadthing/utils.ts at 8e04d9782b194feea74fd6abc2312bd105ae0f5d · ...
File uploads for modern web devs. Contribute to pingdotgg/uploadthing development by creating an account on GitHub.
maybe UPLOADTHING_URL should take presedence over VERCEL_URL - but you shouldn't need a UPLOADTHING_URL if you're on vercel
you'll get the url automatically sorted for you in preview deployments and whatnot
Yes I did so your code, but there is something with the
process.env.*
Because I'm on the Vercel so the process.env.VERCEL_URL
should be populated and I even have the process.env.UPLOADTHING_URL
set.
but the result from that function is localhost and that is the last return of that function...
That means that the process.env.*
is nullish on line 174 and 176 as well.
not sure why the process.env.*
is not evaluated correctly...Would you mind seeing if you're able to make an endpoint that returns your
process.env
to verify that the variables are actually getting into the server?
If the env variables are indeed there, and I was a betting man, I would guess something is going wrong here
I'll do some testing laterI think I know the cause of this, will see if I can get a fix working this afternoon
i just upgraded to 4.1.1 and im now facing the same issue
Will have a fix in 4.1.2 trying to ship tonight.
Didn't mange to ship last night, but 4.1.2 is live now