mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
graceful fail locale
This commit is contained in:
@@ -3,7 +3,7 @@ import { NextResponse, type NextRequest } from "next/server";
|
||||
import { LOCALES } from "@/lib/utils";
|
||||
|
||||
// TODO: Update the protected pages list
|
||||
const PROTECTED_PAGES = ["/monitor", "/build"];
|
||||
const PROTECTED_PAGES = ["/monitor", "/build", "/store/profile", "/store/settings", "/store/dashboard"];
|
||||
const ADMIN_PAGES = ["/admin"];
|
||||
|
||||
export async function updateSession(request: NextRequest, locale: string) {
|
||||
|
||||
@@ -6,11 +6,16 @@ import Negotiator from "negotiator";
|
||||
import { LOCALES, DEFAULT_LOCALE } from "@/lib/utils";
|
||||
|
||||
function getLocale(request: NextRequest) {
|
||||
let headers = Object.fromEntries(request.headers.entries());
|
||||
console.log("Checking headers for locale", headers);
|
||||
let languages = new Negotiator({ headers }).languages();
|
||||
console.log("Languages", languages);
|
||||
return match(languages, LOCALES, DEFAULT_LOCALE);
|
||||
try {
|
||||
let headers = Object.fromEntries(request.headers.entries());
|
||||
console.log("Checking headers for locale", headers);
|
||||
let languages = new Negotiator({ headers }).languages();
|
||||
console.log("Languages", languages);
|
||||
return match(languages, LOCALES, DEFAULT_LOCALE);
|
||||
} catch (error) {
|
||||
console.error("Error getting locale, defaulting to English:", error);
|
||||
return "en";
|
||||
}
|
||||
}
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
|
||||
Reference in New Issue
Block a user