Add note that the bug appears only with trailingSlash: ignore#12130
Conversation
✅ Deploy Preview for astro-docs-2 ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
| }, { | ||
| path: '/', // Critical: ensures cookie works with trailingSlash: "ignore" | ||
| httpOnly: true, | ||
| sameSite: 'lax', | ||
| maxAge: 60 |
There was a problem hiding this comment.
httpOnly, sameSite, maxAge follow best practice, it could remove
There was a problem hiding this comment.
No problem with showing best practices, but we do want to make sure the emphasis here is on supporting how to deal with changed behaviour (since this is the upgrade guide); it's not meant to be a recipe teaching from scratch.
Will ask others to share if they find this helpful or potentially cluttering/distracting!
sarah11918
left a comment
There was a problem hiding this comment.
Thank you for handling this to address the issue, @jp-knj ! 🙌
I will ask others to comment on the extent of the changes here, as I've described below. My instinct is to simply correct the code example in the two places, as I don't feel any of the extra commentary is necessary. I would appreciate the input from others on the team!
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
sarah11918
left a comment
There was a problem hiding this comment.
Alright, let's close an issue! 🎉 Thank you again @jp-knj !
Description (required)
This PR fixes a bug in the v5 upgrade guide's cookie-forwarding example for form actions. The example code was missing a path attribute when setting cookies, which causes actions to fail silently when using trailingSlash: "ignore" (the default with build.format: "directory").
The Problem:
Without an explicit path, cookies default to the request's directory path per RFC 6265. When a POST request to
/routesets a cookie without a path, it's scoped to/route. The subsequent redirect to /route/ (after PR: withastro/astro#13997) can't access this cookie, making it appear as if the action never executed.Related issues & labels (optional)
context.originPathnameincludes the trailing slash when it shouldn't astro#14177 (comment)