Files
accounted/app/.well-known/oauth-protected-resource/[...path]/route.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

28 lines
1.0 KiB
TypeScript

import { NextResponse } from 'next/server'
import {
MCP_RESOURCE_PATH,
buildProtectedResourceMetadata,
} from '@/lib/auth/protected-resource-metadata'
/**
* RFC 9728 §3.1 path-based Protected Resource Metadata:
* `/.well-known/oauth-protected-resource{resource-path}`.
*
* Claude.ai's connector setup derives this URL from the MCP server URL and
* fetches it before any 401 challenge; without it the dialog reports
* "Authorization with Accounted failed". Only the MCP endpoint is a protected
* resource here, so every other path is a 404 rather than a generic answer
* that would advertise resources this server does not serve.
*/
export async function GET(
request: Request,
context: { params: Promise<{ path: string[] }> }
) {
const { path } = await context.params
const resourcePath = '/' + (path ?? []).join('/')
if (resourcePath !== MCP_RESOURCE_PATH) {
return NextResponse.json({ error: 'not_found' }, { status: 404 })
}
return NextResponse.json(buildProtectedResourceMetadata(request))
}