Next.js Discord

Discord Forum

Vercel deploy invalid header error

Unanswered
Indian mackerel posted this in #help-forum
Open in Discord
Indian mackerelOP
Hey, was wondering if anyone has encountered this error before? Happens when I try to deploy to Vercel. It builds fine locally and npm run dev also works, checked all my api calls and middleware, but still having trouble locating where it's coming from. Any ideas would be much appreciated!

value in header item must be string for route {"source":"/api/:path*","headers":[{"key":"Access-Control-Allow-Credentials","value":"true"},{"key":"Access-Control-Allow-Origin"},{"key":"Access-Control-Allow-Methods","value":"GET,DELETE,PATCH,POST,PUT"},{"key":"Access-Control-Allow-Headers","value":"X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"}]}
Error: Invalid header found
Error: Command "npm run build" exited with 1

5 Replies

Indian mackerelOP
uh ... somehow it works in production now, but the preview build still fails. I guess not critical, but if anyone has any info on that, I'd still be keen to hear it.
West African Lion
@Indian mackerel Do you have the code snippet for where this error is coming from? Also how are you trying to launch to Vercel
Indian mackerelOP
no thats exactly the problem. usually I can identify the bug using stack trace or other methods, but in this case I literally copied all the information I have. But seems to be all good, the production deployment seems to run fine now, just the preview not working correctly.
im deploying directly through a github repo
I think it may be an issue in your next.config.mjs file, a missing or incorrect header there. Maybe you can post the content of that file