Skip to content

Conversation

jp-knj
Copy link
Contributor

@jp-knj jp-knj commented Aug 8, 2025

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 /route sets 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)

Copy link

netlify bot commented Aug 8, 2025

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e6e03a6
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/689cb6ca2ca4ab00083e4cb5
😎 Deploy Preview https://deploy-preview-12130--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@astrobot-houston
Copy link
Contributor

astrobot-houston commented Aug 8, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/upgrade-to/v5.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Comment on lines 738 to 742
}, {
path: '/', // Critical: ensures cookie works with trailingSlash: "ignore"
httpOnly: true,
sameSite: 'lax',
maxAge: 60
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

httpOnly, sameSite, maxAge follow best practice, it could remove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@sarah11918 sarah11918 added the code snippet update Updates a code sample: typo, outdated code etc. label Aug 13, 2025
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's close an issue! 🎉 Thank you again @jp-knj !

@sarah11918 sarah11918 merged commit e230d69 into withastro:main Aug 13, 2025
9 of 10 checks passed
ArmandPhilippot added a commit to ArmandPhilippot/astro-docs that referenced this pull request Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code snippet update Updates a code sample: typo, outdated code etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants