File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,21 @@ const withNextIntl = createNextIntlPlugin('./i18n.ts');
55
66const nextConfig : NextConfig = {
77 output : 'standalone' ,
8+ async rewrites ( ) {
9+ return [
10+ // RFC 9728: OAuth metadata at well-known paths for MCP
11+ // Claude Desktop fetches /.well-known/oauth-protected-resource/api/mcp
12+ // Rewrite to our catch-all proxy which serves tenant-aware metadata
13+ {
14+ source : '/.well-known/oauth-protected-resource/:path*' ,
15+ destination : '/api/mcp/.well-known/oauth-protected-resource' ,
16+ } ,
17+ {
18+ source : '/.well-known/oauth-authorization-server/:path*' ,
19+ destination : '/api/mcp/.well-known/oauth-authorization-server' ,
20+ } ,
21+ ] ;
22+ } ,
823} ;
924
1025export default withNextIntl ( nextConfig ) ;
Original file line number Diff line number Diff line change @@ -80,22 +80,6 @@ export default async function proxy(request: NextRequest) {
8080 return NextResponse . next ( )
8181 }
8282
83- // --- OAuth well-known metadata (RFC 9728 path-aware format) ---
84- // Claude Desktop looks for:
85- // /.well-known/oauth-protected-resource/api/mcp
86- // /.well-known/oauth-authorization-server/api/mcp
87- // Rewrite these to our catch-all proxy at /api/mcp/.well-known/*
88- if ( pathname . startsWith ( '/.well-known/oauth-protected-resource/api/mcp' ) ||
89- pathname . startsWith ( '/.well-known/oauth-authorization-server/api/mcp' ) ) {
90- // Extract which well-known type: oauth-protected-resource or oauth-authorization-server
91- const wellKnownType = pathname . startsWith ( '/.well-known/oauth-protected-resource' )
92- ? 'oauth-protected-resource'
93- : 'oauth-authorization-server'
94- const rewriteUrl = request . nextUrl . clone ( )
95- rewriteUrl . pathname = `/api/mcp/.well-known/${ wellKnownType } `
96- return NextResponse . rewrite ( rewriteUrl )
97- }
98-
9983 // --- Tenant Resolution (runs for ALL routes including /api) ---
10084 const host = request . headers . get ( 'host' ) || ''
10185 const tenantSlug = getTenantSlugFromHost ( host )
You can’t perform that action at this time.
0 commit comments