Skip to content

Commit 8776924

Browse files
Rodriguespnclaude
andcommitted
fix: extract function name correctly in oauth-protected-resource redirect
The previous implementation appended /.well-known/oauth-protected-resource to the entire remaining path, causing requests like /.well-known/oauth-protected-resource/functions/v1/func-name/mcp to fail. Now correctly extracts just the function name and ignores sub-paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3762772 commit 8776924

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

internal/start/templates/kong.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ services:
234234
headers:
235235
- "Authorization: {{ .BearerToken }}"
236236
- name: oauth-protected-resource
237-
_comment: "OAuth Protected Resource: /.well-known/oauth-protected-resource/functions/v1/<whatever> -> /functions/v1/<whatever>/.well-known/oauth-protected-resource"
237+
_comment: "OAuth Protected Resource: /.well-known/oauth-protected-resource/functions/v1/<function-name>/* -> /<function-name>/.well-known/oauth-protected-resource"
238238
url: http://{{ .EdgeRuntimeId }}:8081/
239239
routes:
240240
- name: oauth-protected-resource
@@ -248,7 +248,9 @@ services:
248248
access:
249249
- |
250250
local uri = kong.request.get_path()
251-
local new_uri = uri:gsub("^/.well%-known/oauth%-protected%-resource/functions/v1", "") .. "/.well-known/oauth-protected-resource"
251+
local path_after_prefix = uri:gsub("^/.well%-known/oauth%-protected%-resource/functions/v1/", "")
252+
local function_name = path_after_prefix:match("^([^/]+)")
253+
local new_uri = "/" .. function_name .. "/.well-known/oauth-protected-resource"
252254
kong.service.request.set_path(new_uri)
253255
- name: mcp
254256
_comment: "MCP: /mcp -> http://studio:3000/api/mcp"

0 commit comments

Comments
 (0)