✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Error with authentication header causing 500 error on Vercel deployment

3 replies
Last updated: Nov 2, 2022
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
:25:26:54Function Status:
Edge Status:
187.70 ms
Init Duration:
452.30 ms
Memory Used:
97 MB
:iad1::rnkqn-1667298326144-3e8618cfc162User Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ 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) {
Any ideas
Nov 1, 2022, 10:29 AM
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
I don’t think it has to do with the sanity client, as that’s only a warning.
This is the actual error:

ERROR	TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["authorization"]
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?
Nov 2, 2022, 9:09 AM
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.

Was this answer helpful?