mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-01 06:13:15 +00:00
19 lines
523 B
TypeScript
19 lines
523 B
TypeScript
|
|
import { NextRequest, NextResponse } from "next/server";
|
||
|
|
import { GITHUB_TOKEN_COOKIE } from "@open-swe/shared/constants";
|
||
|
|
|
||
|
|
export function middleware(request: NextRequest) {
|
||
|
|
if (request.nextUrl.pathname === "/") {
|
||
|
|
const token = request.cookies.get(GITHUB_TOKEN_COOKIE)?.value;
|
||
|
|
if (token && token.length > 0) {
|
||
|
|
const url = request.nextUrl.clone();
|
||
|
|
url.pathname = "/chat";
|
||
|
|
return NextResponse.redirect(url);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return NextResponse.next();
|
||
|
|
}
|
||
|
|
|
||
|
|
export const config = {
|
||
|
|
matcher: ["/"],
|
||
|
|
};
|