You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unhandled Promise Rejection
TypeError: response.headers.raw is not a function
at setResponse (file:///var/task/node_modules/.pnpm/@astrojs+vercel@2.3.4/node_modules/@astrojs/vercel/dist/serverless/request-transform.js:61:46)
at Server.handler (file:///var/task/node_modules/.pnpm/@astrojs+vercel@2.3.4/node_modules/@astrojs/vercel/dist/serverless/entrypoint.js:22:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5
Rejection: TypeError: response.headers.raw is not a function
at process.<anonymous> (file:///var/runtime/index.mjs:1194:17)
at process.emit (node:events:525:35)
at process.emit (node:domain:489:12)
at emit (node:internal/process/promises:149:20)
at processPromiseRejections (node:internal/process/promises:283:27)
at process.processTicksAndRejections (node:internal/process/task_queues:96:32)
I'm confused on why the developers used that function instead of the result of .get.
Edit: Whie investigating to try to come up with a PR to fix this, I saw the code is copied from SvelteKit, which might ship a custom implementation of Response and Header that supports the non-standard .raw() call.
Given Headers is associated with fetch, which does not involve setting cookies, it seems it does not account for the exception where multiple Set-Cookie headers can be sent.
I'm still looking into other resources to see if there is a well-established approach, otherwise it seems we'll need to split the values manually, given Header.append will join headers with the same key with a comma.
I am willing to submit a pull request for this issue.
The text was updated successfully, but these errors were encountered:
WesSouza
changed the title
@astrojs/vercel issue when returning Response with headers as an object
@astrojs/vercel endpoint breaks when sending set-cookie
Nov 23, 2022
It does seem like we're block on nodejs/undici#1437. SvelteKit seems to go with the split approach, and I don't think there's a nicer way too, so we might have to do that.
What version of
astro
are you using?1.6.10
Are you using an SSR adapter? If so, which one?
Vercel
What is the Node.js version?
18
What package manager are you using?
pnpm
What operating system are you using?
Mac
Describe the Bug
Trying to set a cookie within a Response fails because the code in
request-transform.js
calls a function that is not supported on Vercel's environment.I'm confused on why the developers used that function instead of the result of.get
.Edit: Whie investigating to try to come up with a PR to fix this, I saw the code is copied from SvelteKit, which might ship a custom implementation of
Response
andHeader
that supports the non-standard.raw()
call.Given
Headers
is associated withfetch
, which does not involve setting cookies, it seems it does not account for the exception where multipleSet-Cookie
headers can be sent.I'm still looking into other resources to see if there is a well-established approach, otherwise it seems we'll need to split the values manually, given
Header.append
will join headers with the same key with a comma.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-axnai7?file=src%2Fpages%2Fredirect.ts
Participation
The text was updated successfully, but these errors were encountered: