mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
fix local and preview config
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user