mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
fix typings and edge config key issue
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
import { NextResponse, NextRequest } from "next/server";
|
||||
import { get } from "@vercel/edge-config";
|
||||
|
||||
import { FiefAuth, IUserInfoCache } from "@fief/fief/nextjs";
|
||||
import { getFiefAuth, getFiefAuthMiddleware } from "./app/lib/fief";
|
||||
import { getFiefAuthMiddleware } from "./app/lib/fief";
|
||||
import { getConfig } from "./app/lib/edgeConfig";
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
const domain = request.nextUrl.hostname;
|
||||
const config = await get(domain);
|
||||
|
||||
if (!config) return NextResponse.error();
|
||||
const config = await getConfig(domain);
|
||||
|
||||
// Feature-flag protedted paths
|
||||
if (
|
||||
!config["features"]["browse"] &&
|
||||
!config.features.browse &&
|
||||
request.nextUrl.pathname.startsWith("/browse")
|
||||
) {
|
||||
return NextResponse.redirect(request.nextUrl.origin);
|
||||
}
|
||||
|
||||
if (config["features"]["requireLogin"]) {
|
||||
if (config.features.requireLogin) {
|
||||
const fiefMiddleware = await getFiefAuthMiddleware(request.nextUrl);
|
||||
const fiefResponse = fiefMiddleware(request);
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user