fix: support edge runtime

This commit is contained in:
swve 2023-04-11 23:31:17 +02:00
parent 7869b6fd7f
commit bb555fc3e0
2 changed files with 3 additions and 3 deletions

View file

@ -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

View file

@ -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;