feat(codex): Cursor compatibility + Next.js 16 proxy migration
- Force streaming for Codex/OpenAI models to fix non-streaming bug - Strip unsupported params (user, metadata, stream_options, prompt_cache_retention) - Force response translation from openai-responses to openai format - Migrate middleware.js to proxy.js for Next.js 16 - Use webpack explicitly in dev/build scripts - Updated Codex User-Agent
This commit is contained in:
parent
814e02ae31
commit
7b864a9dcb
7 changed files with 85 additions and 51 deletions
37
src/proxy.js
Normal file
37
src/proxy.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { jwtVerify } from "jose";
|
||||
|
||||
const SECRET = new TextEncoder().encode(
|
||||
process.env.JWT_SECRET || "9router-default-secret-change-me"
|
||||
);
|
||||
|
||||
export async function proxy(request) {
|
||||
const { pathname } = request.nextUrl;
|
||||
|
||||
// Protect all dashboard routes
|
||||
if (pathname.startsWith("/dashboard")) {
|
||||
const token = request.cookies.get("auth_token")?.value;
|
||||
|
||||
if (!token) {
|
||||
return NextResponse.redirect(new URL("/login", request.url));
|
||||
}
|
||||
|
||||
try {
|
||||
await jwtVerify(token, SECRET);
|
||||
return NextResponse.next();
|
||||
} catch (err) {
|
||||
return NextResponse.redirect(new URL("/login", request.url));
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect / to /dashboard if logged in, or /dashboard if it's the root
|
||||
if (pathname === "/") {
|
||||
return NextResponse.redirect(new URL("/dashboard", request.url));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/", "/dashboard/:path*"],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue