File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import {
3232import { DIRECT_TOOL_DEFS , SUBAGENT_TOOL_DEFS } from '@/lib/copilot/tools/mcp/definitions'
3333import { env } from '@/lib/core/config/env'
3434import { RateLimiter } from '@/lib/core/rate-limiter'
35+ import { getBaseUrl } from '@/lib/core/utils/urls'
3536import {
3637 authorizeWorkflowByWorkspacePermission ,
3738 resolveWorkflowIdForUser ,
@@ -542,7 +543,8 @@ export async function POST(request: NextRequest) {
542543 const hasAuth = request . headers . has ( 'authorization' ) || request . headers . has ( 'x-api-key' )
543544
544545 if ( ! hasAuth ) {
545- const resourceMetadataUrl = `${ request . nextUrl . origin } /.well-known/oauth-protected-resource/api/mcp/copilot`
546+ const origin = getBaseUrl ( ) . replace ( / \/ $ / , '' )
547+ const resourceMetadataUrl = `${ origin } /.well-known/oauth-protected-resource/api/mcp/copilot`
546548 return new NextResponse ( JSON . stringify ( { error : 'unauthorized' } ) , {
547549 status : 401 ,
548550 headers : {
Original file line number Diff line number Diff line change 11import { type NextRequest , NextResponse } from 'next/server'
2+ import { getBaseUrl } from '@/lib/core/utils/urls'
23
3- function getOrigin ( request : NextRequest ) : string {
4- return request . nextUrl . origin
4+ function getOrigin ( ) : string {
5+ return getBaseUrl ( ) . replace ( / \/ $ / , '' )
56}
67
78export function createMcpAuthorizationServerMetadataResponse ( request : NextRequest ) : NextResponse {
8- const origin = getOrigin ( request )
9+ const origin = getOrigin ( )
910 const resource = `${ origin } /api/mcp/copilot`
1011
1112 return NextResponse . json (
@@ -35,7 +36,7 @@ export function createMcpAuthorizationServerMetadataResponse(request: NextReques
3536}
3637
3738export function createMcpProtectedResourceMetadataResponse ( request : NextRequest ) : NextResponse {
38- const origin = getOrigin ( request )
39+ const origin = getOrigin ( )
3940 const resource = `${ origin } /api/mcp/copilot`
4041 const authorizationServerIssuer = origin
4142
You can’t perform that action at this time.
0 commit comments