feat: v1 — persistent shell, model gateway, artifact improvements (#1462)

This commit is contained in:
dancer 2026-03-20 09:37:02 +00:00 committed by GitHub
parent 3651670fb9
commit f9652b452a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
161 changed files with 5166 additions and 8009 deletions

View file

@ -1,12 +1,10 @@
import { type NextRequest, NextResponse } from "next/server";
import { getToken } from "next-auth/jwt";
import { guestRegex, isDevelopmentEnvironment } from "./lib/constants";
export function proxy(request: NextRequest) {
export async function proxy(request: NextRequest) {
const { pathname } = request.nextUrl;
/*
* Playwright starts the dev server and requires a 200 status to
* begin the tests, so this ensures that the tests can start
*/
if (pathname.startsWith("/ping")) {
return new Response("pong", { status: 200 });
}
@ -15,6 +13,28 @@ export function proxy(request: NextRequest) {
return NextResponse.next();
}
const token = await getToken({
req: request,
secret: process.env.AUTH_SECRET,
secureCookie: !isDevelopmentEnvironment,
});
const base = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
if (!token) {
const redirectUrl = encodeURIComponent(new URL(request.url).pathname);
return NextResponse.redirect(
new URL(`${base}/api/auth/guest?redirectUrl=${redirectUrl}`, request.url)
);
}
const isGuest = guestRegex.test(token?.email ?? "");
if (token && !isGuest && ["/login", "/register"].includes(pathname)) {
return NextResponse.redirect(new URL(`${base}/`, request.url));
}
return NextResponse.next();
}
@ -26,12 +46,6 @@ export const config = {
"/login",
"/register",
/*
* Match all request paths except for the ones starting with:
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico, sitemap.xml, robots.txt (metadata files)
*/
"/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
],
};