diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index fad0cc61..5291a79a 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -1,4 +1,15 @@ import { get } from "@vercel/edge-config"; +import { isDevelopment } from "./utils"; + +const localConfig = { + features: { + requireLogin: true, + privacy: true, + browse: true, + }, + api_url: "http://127.0.0.1:1250", + auth_callback_url: "http://localhost:3000/auth-callback", +}; type EdgeConfig = { [domainWithDash: string]: { @@ -23,7 +34,14 @@ export function edgeDomainToKey(domain: string) { // get edge config server-side (prefer DomainContext when available), domain is the hostname export async function getConfig(domain: string) { - const config = await get(edgeDomainToKey(domain)); + if (isDevelopment()) { + return localConfig; + } + + let config = await get(edgeDomainToKey(domain)); + console.warn("No config for this domain, falling back to default"); + + config = await get(edgeDomainToKey("default")); if (typeof config !== "object") throw Error("Error fetchig config"); diff --git a/www/middleware.ts b/www/middleware.ts index f5b6059b..4bf13ed0 100644 --- a/www/middleware.ts +++ b/www/middleware.ts @@ -1,5 +1,4 @@ import { NextResponse, NextRequest } from "next/server"; -import { get } from "@vercel/edge-config"; import { getFiefAuthMiddleware } from "./app/lib/fief"; import { getConfig } from "./app/lib/edgeConfig";