mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 12:19:06 +00:00
nextjs magic
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { get } from "@vercel/edge-config";
|
import { get } from "@vercel/edge-config";
|
||||||
|
import { isBuildPhase } from "./next";
|
||||||
|
|
||||||
type EdgeConfig = {
|
type EdgeConfig = {
|
||||||
[domainWithDash: string]: {
|
[domainWithDash: string]: {
|
||||||
@@ -29,8 +30,12 @@ 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() {
|
export async function getConfig() {
|
||||||
if (process.env.NEXT_PUBLIC_ENV === "development") {
|
if (process.env.NEXT_PUBLIC_ENV === "development") {
|
||||||
// helps to stop nextjs build from eager loading. don't "require()" it
|
try {
|
||||||
return (await import("../../config")).localConfig;
|
return require("../../config").localConfig;
|
||||||
|
} catch (e) {
|
||||||
|
if (!isBuildPhase) throw new Error(e);
|
||||||
|
return require("../../config-template").localConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const domain = new URL(process.env.NEXT_PUBLIC_SITE_URL!).hostname;
|
const domain = new URL(process.env.NEXT_PUBLIC_SITE_URL!).hostname;
|
||||||
|
|||||||
Reference in New Issue
Block a user