From bb555fc3e03a5ac65c79ca660d620d135dee644f Mon Sep 17 00:00:00 2001 From: swve Date: Tue, 11 Apr 2023 23:31:17 +0200 Subject: [PATCH] fix: support edge runtime --- front/middleware.ts | 4 ++-- front/services/config/config.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front/middleware.ts b/front/middleware.ts index 56fd95cd..f78c3cf4 100644 --- a/front/middleware.ts +++ b/front/middleware.ts @@ -1,4 +1,4 @@ -import { getDefaultOrg, getSelfHostedOption } from "@services/config/config"; +import { LEARNHOUSE_DOMAIN, getDefaultOrg, getSelfHostedOption } from "./services/config/config"; import { NextRequest, NextResponse } from "next/server"; export const config = { @@ -19,7 +19,7 @@ export default function middleware(req: NextRequest) { const url = req.nextUrl; const isSelfHosted = getSelfHostedOption(); const hostname = req.headers.get("host") || "learnhouse.app"; - let currentHost = hostname.replace(".localhost:3000", ""); + let currentHost = hostname.replace(`.${LEARNHOUSE_DOMAIN}`, ""); if (!isSelfHosted && currentHost === "localhost:3000" && !url.pathname.startsWith("/organizations")) { // Redirect to error page if not self-hosted and on localhost diff --git a/front/services/config/config.ts b/front/services/config/config.ts index 401b7000..ed5ee7e4 100644 --- a/front/services/config/config.ts +++ b/front/services/config/config.ts @@ -1,7 +1,7 @@ const LEARNHOUSE_HTTP_PROTOCOL = process.env.NEXT_PUBLIC_LEARNHOUSE_HTTPS === "true" ? "https://" : "http://"; const LEARNHOUSE_API_URL = `${process.env.NEXT_PUBLIC_LEARNHOUSE_API_URL}`; const LEARNHOUSE_BACKEND_URL = `${process.env.NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL}`; -const LEARNHOUSE_DOMAIN = process.env.NEXT_PUBLIC_LEARNHOUSE_DOMAIN; +export const LEARNHOUSE_DOMAIN = process.env.NEXT_PUBLIC_LEARNHOUSE_DOMAIN; export const getAPIUrl = () => LEARNHOUSE_API_URL; export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;