fix(auth): use placeholder config during CI build to avoid module-level throw
Deploy to route.crispygoat.com / deploy (push) Failing after 2m56s
Deploy to route.crispygoat.com / deploy (push) Failing after 2m56s
This commit is contained in:
+15
-3
@@ -26,15 +26,27 @@ export interface NeonAuthBaseConfig {
|
|||||||
* Called by both the edge middleware and the Node-only auth lib.
|
* Called by both the edge middleware and the Node-only auth lib.
|
||||||
*/
|
*/
|
||||||
export function getNeonAuthConfig(): NeonAuthBaseConfig {
|
export function getNeonAuthConfig(): NeonAuthBaseConfig {
|
||||||
const baseUrl = process.env.NEON_AUTH_BASE_URL;
|
const baseUrl = process.env.NEON_AUTH_BASE_URL || "";
|
||||||
if (!baseUrl) {
|
const cookieSecret = process.env.NEON_AUTH_COOKIE_SECRET || "";
|
||||||
|
|
||||||
|
// Detect CI build context: DATABASE_URL is set (Build step), NEON_AUTH_BASE_URL is empty.
|
||||||
|
// In this case, return a placeholder so `next build` succeeds — auth will be validated
|
||||||
|
// at runtime when actually needed.
|
||||||
|
const isCIBuild = !!process.env.DATABASE_URL && !baseUrl;
|
||||||
|
|
||||||
|
if (!baseUrl || baseUrl === "placeholder") {
|
||||||
|
if (isCIBuild) {
|
||||||
|
return { baseUrl: "https://placeholder.local", cookieSecret: "dev-cookie-secret-placeholder-32chars!!" };
|
||||||
|
}
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"NEON_AUTH_BASE_URL is not set. Run `neonctl neon-auth status` to get the value."
|
"NEON_AUTH_BASE_URL is not set. Run `neonctl neon-auth status` to get the value."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const cookieSecret = process.env.NEON_AUTH_COOKIE_SECRET;
|
|
||||||
if (!cookieSecret) {
|
if (!cookieSecret) {
|
||||||
|
if (isCIBuild) {
|
||||||
|
return { baseUrl, cookieSecret: "dev-cookie-secret-placeholder-32chars!!" };
|
||||||
|
}
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"NEON_AUTH_COOKIE_SECRET is not set. Generate one: openssl rand -base64 32"
|
"NEON_AUTH_COOKIE_SECRET is not set. Generate one: openssl rand -base64 32"
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user