Next.js Discord

Discord Forum

Axios and Fetch error only on Vercel (working fine on localhost)

Unanswered
Lucas Bonafé posted this in #help-forum
Open in Discord
"Request failed with status code 401" and "Unexpected end of JSON input", full details on:
https://stackoverflow.com/questions/78780933/axios-and-fetch-error-only-on-vercel-working-fine-on-localhost

If you don't have a suggestion and still want to help, you can upvote this post or the Stack Overflow post, please...

6 Replies

@Lucas Bonafé I believe you are not getting ASAAS_API_KEY env variable. 401 means unauthorized
check if you have your api key in vercel envs
@James4u <@327558872892178434> I believe you are not getting `ASAAS_API_KEY` env variable. 401 means unauthorized
If I put a console.log(process.env.ASAAS_API_KEY), I get the key as an answer, it is properly configured in Vercel's environment variable settings...
If it works normally on localhost and the environment variables are set correctly on both, can I modify the runtime to be as similar as possible to localhost through these parameters?
https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes
I've already tested modifying GET requests to POST and the error persists...
I finally solved!