Skip to content

Commit c59457d

Browse files
authored
fix: trying resource metadata failure for mcp auth (supermemoryai#858)
1 parent b8e5376 commit c59457d

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

apps/mcp/src/index.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,18 @@ const handleMcpRequest = async (c: Context<{ Bindings: Bindings }>) => {
114114
const token = authHeader?.replace(/^Bearer\s+/i, "")
115115
const containerTag = c.req.header("x-sm-project")
116116
const apiUrl = c.env.API_URL || DEFAULT_API_URL
117-
118-
const reqHost = c.req.header("x-forwarded-host") || c.req.header("host") || ""
119-
const reqProto = c.req.header("x-forwarded-proto") || "https"
120-
const resourceMetadataUrl = reqHost
121-
? `${reqProto}://${reqHost}/.well-known/oauth-protected-resource`
122-
: "/.well-known/oauth-protected-resource"
117+
const mcpURL =
118+
c.env.API_URL === "http://localhost:8787"
119+
? "http://localhost:8788"
120+
: "https://mcp.supermemory.ai"
121+
122+
// TODO: commented out because this might be issue with auth
123+
//const reqHost = c.req.header("x-forwarded-host") || c.req.header("host") || ""
124+
//const reqProto = c.req.header("x-forwarded-proto") || "https"
125+
//const resourceMetadataUrl = reqHost
126+
// ? `${reqProto}://${reqHost}/.well-known/oauth-protected-resource`
127+
// : "/.well-known/oauth-protected-resource"
128+
const resourceMetadataUrl = `${mcpURL}/.well-known/oauth-protected-resource`
123129

124130
if (!token) {
125131
return new Response("Unauthorized", {

0 commit comments

Comments
 (0)