Hey everyone! ⚓
We are hitting a wall with customer session persistence in Medusa v2 (v2.13.4) using the Next.js 15 Starter (React 19).
The Issue:
Customer login via emailpass returns a 200 OK, but the session is lost immediately on the next page load or route transition. This is especially broken on iOS Safari, leading to constant throwOnHydrationMismatch errors as the UI toggles between Guest and Authenticated states.
Our Setup:
• Backend: Medusa v2.13.4
• Storefront: Next.js 15 (App Router)
• Env: Subdomains (admin.example.com vs www.example.com)
The Weird Part (Config):
In our medusa-config.ts, we’ve tried forcing cookie settings, but the defineConfig type for v2 doesn't seem to recognize them, forcing us to use @ts-ignore:
// medusa-config.ts -> projectConfig.http
// @ts-ignore
cookieDomain: ".example.com",
// @ts-ignore
cookieSameSite: "lax",
// @ts-ignore
cookieSecure: true,
Questions:
- What is the "v2 way" to globally configure cookieDomain and SameSite since they aren't in the standard http type anymore?
- With Next.js 15, do we need to manually sync the JWT/Cookie in middleware.ts to ensure Server Components see the session?
- Any known issues with iOS Safari ITP and Medusa v2's default cookie handling?
Any "recipes" or pointers to stable multi-subdomain auth would be life-saving! Thanks! 🙏