Refactor cookie domain logic to only apply in production#730
Open
Refactor cookie domain logic to only apply in production#730
Conversation
The mode and theme cookie domain was being set unconditionally using the DOMAIN env var. When accessing dev instances via localhost, this caused the cookies to not be saved because the domain didn't match. This fix aligns with the session cookie behavior in session.server.ts which already checks VERCEL_ENV === "production" before setting domain. Slack thread: https://carbon-ms.slack.com/archives/C0B0LQQEB0B/p1777530058258979 https://claude.ai/code/session_016YP8oTpJahKNjZQbWfrpP2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR refactors the cookie domain configuration logic across multiple applications (academy, erp, mes, starter) to:
VERCEL_ENV === "production")getCookieDomain()utility function instead of manual domain validation!DOMAIN.startsWith("localhost"))The changes ensure that cookie domain settings are only applied in production, preventing potential cookie issues in development and staging environments.
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
VERCEL_ENV === "production"), cookies are set with the appropriate domaingetCookieDomain()utility properly validates and returns the domain or nullNo manual testing required beyond verifying the environment variable behavior is correct.
Checklist
https://claude.ai/code/session_016YP8oTpJahKNjZQbWfrpP2