Error with authentication header causing 500 error on Vercel deployment
3 replies
Last updated: Nov 2, 2022
A
Hey everyone, I've built a blog using sanity and it works perfectly on localhost but I get this error on vercel and my custom domain
[POST] /api/createComment
11
:25:26:54Function Status:
500
Edge Status:
500
Duration:
187.70 ms
Init Duration:
452.30 ms
Memory Used:
97 MB
ID:
fra1:
:iad1::rnkqn-1667298326144-3e8618cfc162User Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Any ideas
[POST] /api/createComment
11
:25:26:54Function Status:
500
Edge Status:
500
Duration:
187.70 ms
Init Duration:
452.30 ms
Memory Used:
97 MB
ID:
fra1:
:iad1::rnkqn-1667298326144-3e8618cfc162User Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
2022-11-01T10:25:27.398Z 9d7c638c-8015-4f29-b2a9-48627dd96809 WARN Using the Sanity client without specifying an API version is deprecated. See <https://docs.sanity.io/help/js-client-api-version> 2022-11-01T10:25:27.439Z 9d7c638c-8015-4f29-b2a9-48627dd96809 ERROR TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["authorization"] at ClientRequest.setHeader (node:_http_outgoing:579:3) at new ClientRequest (node:_http_client:262:14) at Object.request (node:https:353:10) at module.exports (/var/task/node_modules/get-it/lib-node/request/node-request.js:133:29) at /var/task/node_modules/get-it/lib-node/index.js:50:24 at Object.publish (/var/task/node_modules/nano-pubsub/index.js:18:22) at Observable._subscribe (/var/task/node_modules/get-it/lib/middleware/observable.js:32:26) at Observable._trySubscribe (/var/task/node_modules/rxjs/internal/Observable.js:44:25) at Observable.subscribe (/var/task/node_modules/rxjs/internal/Observable.js:30:22) at Observable._subscribe (/var/task/node_modules/@sanity/client/lib/sanityClient.js:123:68) { code: 'ERR_INVALID_CHAR' }
Nov 1, 2022, 10:29 AM
Hey
user M
! If you follow the link in that error it'll show you how to set an API version on your client. That should clear up the error!Nov 1, 2022, 5:09 PM
A
I don’t think it has to do with the sanity client, as that’s only a warning.
This is the actual error:
I’m seeing this same error on my next.js revalidate webhook endpoint on Vercel. Could it be perhaps that the authentication header of the webhooks have changed on the Sanity end?
I wonder if not more people see their webhooks failing?
This is the actual error:
ERROR TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["authorization"]
I wonder if not more people see their webhooks failing?
Nov 2, 2022, 9:09 AM
A
Hey, thanks for the replys. Simple mistake. Just had a blank space included at the end of the API token in vercel.
Nov 2, 2022, 10:07 AM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.