| 12345678910111213141516171819202122232425262728 |
- /**
- * Helpers for first-party Briven Auth proxy (same pattern as Mavi).
- * Browser → /api/auth/* → https://api.briven.tech/v1/auth-core/fdi/*
- */
- /** Strip Domain= so Set-Cookie sticks to localhost / your app host. */
- export function rewriteSetCookieForFirstParty(setCookie: string): string {
- return setCookie
- .replace(/;\s*[Dd]omain=[^;]*/g, "")
- .replace(/;\s*[Ss]ame[Ss]ite=None/gi, "; SameSite=Lax");
- }
- export function brivenUpstreamOrigin(): string {
- return (
- process.env.BRIVEN_API_ORIGIN ||
- process.env.NEXT_PUBLIC_BRIVEN_API_ORIGIN ||
- "https://api.briven.tech"
- ).replace(/\/$/, "");
- }
- export function collectSetCookies(headers: Headers): string[] {
- const anyHeaders = headers as Headers & { getSetCookie?: () => string[] };
- if (typeof anyHeaders.getSetCookie === "function") {
- return anyHeaders.getSetCookie();
- }
- const single = headers.get("set-cookie");
- return single ? [single] : [];
- }
|