mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
fix local and preview config
This commit is contained in:
@@ -1,4 +1,15 @@
|
|||||||
import { get } from "@vercel/edge-config";
|
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 = {
|
type EdgeConfig = {
|
||||||
[domainWithDash: string]: {
|
[domainWithDash: string]: {
|
||||||
@@ -23,7 +34,14 @@ export function edgeDomainToKey(domain: string) {
|
|||||||
|
|
||||||
// get edge config server-side (prefer DomainContext when available), domain is the hostname
|
// get edge config server-side (prefer DomainContext when available), domain is the hostname
|
||||||
export async function getConfig(domain: string) {
|
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");
|
if (typeof config !== "object") throw Error("Error fetchig config");
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { NextResponse, NextRequest } from "next/server";
|
import { NextResponse, NextRequest } from "next/server";
|
||||||
import { get } from "@vercel/edge-config";
|
|
||||||
|
|
||||||
import { getFiefAuthMiddleware } from "./app/lib/fief";
|
import { getFiefAuthMiddleware } from "./app/lib/fief";
|
||||||
import { getConfig } from "./app/lib/edgeConfig";
|
import { getConfig } from "./app/lib/edgeConfig";
|
||||||
|
|||||||
Reference in New Issue
Block a user