-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding cookies to api route response [simple result] #5060
Conversation
🦋 Changeset detectedLatest commit: 79bb937 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Looks good overall! Just one thing about how the cookies are set in dev. Love the example update to use Astro.cookies as well! |
res.writeHead(200, { 'Content-Type': `${contentType};charset=utf-8` }); | ||
res.end(result.body); | ||
const response = new Response(result.body, { | ||
status: 200, | ||
headers: { | ||
'Content-Type': `${contentType};charset=utf-8`, | ||
}, | ||
}); | ||
attachToResponse(response, result.cookies); | ||
await writeWebResponse(res, response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I converted the direct writing to the response to a call to writeWebResponse
in order to streamline the response handling. Also added a call to attachToResponse
in order to connect the cookie
to the response.
This looks great, thank you! |
Changes
simple
object]simple
,Response
)ssr
to use the build in cookie handling vs lightcookie 3rd partyTesting
ssr
from the repobuild -> preview with node
anddev
Docs