Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
🔨 chore: add 'cookieUrl'
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Apr 27, 2021
1 parent d65e2c2 commit 8eb4495
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks/useCookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ export function useCookie(
secure: config.secureCookie,
};

if (config.cookieUrl) {
options.domain = config.cookieUrl;
}

res.setHeader("Set-Cookie", serialize(name, token, options));
}
3 changes: 3 additions & 0 deletions src/lib/config.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface ServerConfig {
env: string;
allowIframes: boolean;
secureCookie: boolean;
cookieUrl: string | null;
}

/**
Expand Down Expand Up @@ -37,6 +38,7 @@ try {
env: conf.default.env || defaultProfile,
allowIframes: conf.default?.allowIframes ?? false,
secureCookie: conf.default?.secureCookie ?? false,
cookieUrl: conf.default.cookieUrl || null,
};
} catch (e) {
config = {
Expand All @@ -49,6 +51,7 @@ try {
env: process.env.PROFILE || defaultProfile,
allowIframes: process.env.ALLOW_IFRAMES === "true" ?? false,
secureCookie: process.env.SECURE_COOKIE === "true" ?? false,
cookieUrl: process.env.COOKIE_URL! || null,
};
}

Expand Down

0 comments on commit 8eb4495

Please sign in to comment.