mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-25 08:31:37 -05:00
fix(mcp): return origin url as authorization server (#6397)
This commit is contained in:
@@ -93,10 +93,11 @@ export const getMCPProtectedResourceMetadata = (
|
||||
options?: MCPOptions | undefined,
|
||||
) => {
|
||||
const baseURL = ctx.context.baseURL;
|
||||
const origin = new URL(baseURL).origin;
|
||||
|
||||
return {
|
||||
resource: options?.resource ?? new URL(baseURL).origin,
|
||||
authorization_servers: [baseURL],
|
||||
resource: options?.resource ?? origin,
|
||||
authorization_servers: [origin],
|
||||
jwks_uri: options?.oidcConfig?.metadata?.jwks_uri ?? `${baseURL}/mcp/jwks`,
|
||||
scopes_supported: options?.oidcConfig?.metadata?.scopes_supported ?? [
|
||||
"openid",
|
||||
|
||||
@@ -368,10 +368,11 @@ describe("mcp", async () => {
|
||||
const metadata = await serverClient.$fetch(
|
||||
"/.well-known/oauth-protected-resource",
|
||||
);
|
||||
const origin = new URL(baseURL).origin;
|
||||
|
||||
expect(metadata.data).toMatchObject({
|
||||
resource: baseURL,
|
||||
authorization_servers: [`${baseURL}/api/auth`],
|
||||
resource: origin,
|
||||
authorization_servers: [origin],
|
||||
jwks_uri: `${baseURL}/api/auth/mcp/jwks`,
|
||||
scopes_supported: ["openid", "profile", "email", "offline_access"],
|
||||
bearer_methods_supported: ["header"],
|
||||
|
||||
Reference in New Issue
Block a user