Support sub-path deploy via NEXT_PUBLIC_BASE_PATH (loma.chat/pagiva)
Adds basePath config, withBase/appUrl helpers, base-path-aware cookies, OAuth redirects, manifest, service worker and cron runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { BASE_PATH, appUrl } from "@/lib/base-path";
|
||||
import { SignJWT, jwtVerify } from "jose";
|
||||
import type { AuthProvider } from "@prisma/client";
|
||||
import { prisma } from "@/lib/db";
|
||||
@@ -16,7 +17,7 @@ export const SOCIAL_PROVIDERS = ["google", "facebook"] as const;
|
||||
export type SocialProvider = (typeof SOCIAL_PROVIDERS)[number];
|
||||
|
||||
export const SOCIAL_STATE_COOKIE = "pm_social_oauth";
|
||||
export const SOCIAL_STATE_PATH = "/api/auth/oauth";
|
||||
export const SOCIAL_STATE_PATH = `${BASE_PATH}/api/auth/oauth`;
|
||||
export const SOCIAL_STATE_TTL_SECONDS = 10 * 60;
|
||||
|
||||
const DB_PROVIDER: Record<SocialProvider, AuthProvider> = { google: "GOOGLE", facebook: "FACEBOOK" };
|
||||
@@ -75,7 +76,7 @@ export function safeRedirectPath(raw: string | null | undefined): string {
|
||||
}
|
||||
|
||||
function redirectUri(provider: SocialProvider, origin: string): string {
|
||||
return `${process.env.NEXT_PUBLIC_APP_URL || origin}/api/auth/oauth/${provider}/callback`;
|
||||
return `${appUrl(origin)}/api/auth/oauth/${provider}/callback`;
|
||||
}
|
||||
|
||||
// ---------- state ----------
|
||||
|
||||
Reference in New Issue
Block a user