mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-03-18 22:01:55 +01:00
* Migrate standard answers implementations to ee/ * renaming * Clean up slackbot non-ee standard answers import * Move backend api/manage/standard_answer route to ee * Move standard answers web UI to ee * Hide standard answer controls in bot edit page * Kwargs for fetch_versioned_implementation * Add docstring explaining return types for handle_standard_answers * Consolidate blocks into ee/handle_standard_answers --------- Co-authored-by: Hyeong Joon Suh <hyeongjoonsuh@Hyeongs-MacBook-Pro.local> Co-authored-by: danswer-trial <danswer-trial@danswer-trials-MacBook-Pro.local>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
import { SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED } from "./lib/constants";
|
|
|
|
const eePaths = [
|
|
"/admin/groups",
|
|
"/admin/api-key",
|
|
"/admin/performance/usage",
|
|
"/admin/performance/query-history",
|
|
"/admin/whitelabeling",
|
|
"/admin/performance/custom-analytics",
|
|
"/admin/standard-answer",
|
|
];
|
|
|
|
const eePathsForMatcher = eePaths.map((path) => `${path}/:path*`);
|
|
|
|
export async function middleware(request: NextRequest) {
|
|
if (SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED) {
|
|
const pathname = request.nextUrl.pathname;
|
|
|
|
// Check if the current path is in the eePaths list
|
|
if (eePaths.some((path) => pathname.startsWith(path))) {
|
|
// Add '/ee' to the beginning of the pathname
|
|
const newPathname = `/ee${pathname}`;
|
|
|
|
// Create a new URL with the modified pathname
|
|
const newUrl = new URL(newPathname, request.url);
|
|
|
|
// Rewrite to the new URL
|
|
return NextResponse.rewrite(newUrl);
|
|
}
|
|
}
|
|
|
|
// Continue with the response if no rewrite is needed
|
|
return NextResponse.next();
|
|
}
|
|
|
|
// Specify the paths that the middleware should run for
|
|
export const config = {
|
|
matcher: eePathsForMatcher,
|
|
};
|