mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
feat: replace nextjs-config with environment variables (#632)
* chore: remove nextjs-config * build fix * update readme * explicit nextjs env vars + remove feature-unrelated things and obsolete vars from config * full config removal * remove force-dynamic from pages * compile fix * restore claude-deleted tests * better .env.example --------- Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { withAuth } from "next-auth/middleware";
|
||||
import { getConfig } from "./app/lib/edgeConfig";
|
||||
import { featureEnabled } from "./app/lib/features";
|
||||
import { NextResponse } from "next/server";
|
||||
import { PROTECTED_PAGES } from "./app/lib/auth";
|
||||
|
||||
@@ -19,13 +19,12 @@ export const config = {
|
||||
|
||||
export default withAuth(
|
||||
async function middleware(request) {
|
||||
const config = await getConfig();
|
||||
const pathname = request.nextUrl.pathname;
|
||||
|
||||
// feature-flags protected paths
|
||||
if (
|
||||
(!config.features.browse && pathname.startsWith("/browse")) ||
|
||||
(!config.features.rooms && pathname.startsWith("/rooms"))
|
||||
(!featureEnabled("browse") && pathname.startsWith("/browse")) ||
|
||||
(!featureEnabled("rooms") && pathname.startsWith("/rooms"))
|
||||
) {
|
||||
return NextResponse.redirect(request.nextUrl.origin);
|
||||
}
|
||||
@@ -33,10 +32,8 @@ export default withAuth(
|
||||
{
|
||||
callbacks: {
|
||||
async authorized({ req, token }) {
|
||||
const config = await getConfig();
|
||||
|
||||
if (
|
||||
config.features.requireLogin &&
|
||||
featureEnabled("requireLogin") &&
|
||||
PROTECTED_PAGES.test(req.nextUrl.pathname)
|
||||
) {
|
||||
return !!token;
|
||||
|
||||
Reference in New Issue
Block a user