Merge branch 'next' of https://github.com/useplunk/plunk into next
This commit is contained in:
@@ -10,6 +10,7 @@ import {Keys} from './keys.js';
|
|||||||
* Extract base domain from URL for cookie sharing across subdomains
|
* Extract base domain from URL for cookie sharing across subdomains
|
||||||
* e.g., "http://api.example.com" -> ".example.com"
|
* e.g., "http://api.example.com" -> ".example.com"
|
||||||
* e.g., "http://api.localhost" -> ".localhost"
|
* e.g., "http://api.localhost" -> ".localhost"
|
||||||
|
* e.g., "http://app.plunk.local" -> ".plunk.local"
|
||||||
*/
|
*/
|
||||||
function getCookieDomain(): string | undefined {
|
function getCookieDomain(): string | undefined {
|
||||||
if (NODE_ENV === 'development') {
|
if (NODE_ENV === 'development') {
|
||||||
@@ -28,10 +29,14 @@ function getCookieDomain(): string | undefined {
|
|||||||
// Extract base domain (last two parts for most domains, or .localhost)
|
// Extract base domain (last two parts for most domains, or .localhost)
|
||||||
const parts = hostname.split('.');
|
const parts = hostname.split('.');
|
||||||
if (parts.length >= 2) {
|
if (parts.length >= 2) {
|
||||||
// For *.localhost or *.local, use the full hostname with leading dot
|
// For *.localhost, use .localhost (reserved TLD)
|
||||||
if (hostname.endsWith('.localhost') || hostname.endsWith('.local')) {
|
if (hostname.endsWith('.localhost')) {
|
||||||
return '.localhost';
|
return '.localhost';
|
||||||
}
|
}
|
||||||
|
// For *.local (mDNS TLD), use the actual base domain
|
||||||
|
if (hostname.endsWith('.local')) {
|
||||||
|
return `.${parts.slice(-2).join('.')}`;
|
||||||
|
}
|
||||||
// For other domains, use the last two parts (e.g., .example.com)
|
// For other domains, use the last two parts (e.g., .example.com)
|
||||||
return `.${parts.slice(-2).join('.')}`;
|
return `.${parts.slice(-2).join('.')}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user