ory / integrations

Apache License 2.0
19 stars 24 forks source link

nextjs problem without forwarding headers #65

Open elbotho opened 5 months ago

elbotho commented 5 months ago

Since yesterday we had a problem with the calls to our kratos api route api/ory/[...paths].ts always returning 500. It did not depend on any changes / updates on our side and my best guess is that vervel changed something on their end.

Afer a lot of debugging I got it to work again with the following options:

export default createApiHandler({
  …
  forwardAdditionalHeaders: [
    'x-vercel-internal-timing',
    'x-vercel-cache',
    'x-vercel-id',
  ],
})

Maybe this helps someone else out. You probably don't need all the headers, but only x-vercel-internal-timing did not work.

Full error message Uncaught Exception: TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "x-vercel-internal-timing" at ServerResponse.setHeader (node:_http_outgoing:662:3) at h.setHeader (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:20:5747) at n.writeHead (/opt/rust/nodejs.js:7:2551) at ServerResponse._implicitHeader (node:_http_server:338:8) at write_ (node:_http_outgoing:945:9) at ServerResponse.end (node:_http_outgoing:1056:5) at K.r.end (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:13330) at /var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:14144 at K.r.send (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:14153) at Request. (/var/task/node_modules/@ory/integrations/next-edge/index.js:116:17) { code: 'ERR_HTTP_INVALID_HEADER_VALUE' } Node.js process exited with exit status: 129. The logs above can help with debugging the issue. Unknown application error occurred