Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(nginx): update well-known endpoints to serve MCP OAuth discovery JSON

Andrejf8df338429a3
diff --git a/apps/web/env.sh b/apps/web/env.sh
index 02f25d3d3..ebd63d145 100644
--- a/apps/web/env.sh
+++ b/apps/web/env.sh
@@ -14,15 +14,19 @@ if [ ! -z "$KANEO_API_URL" ]; then
# Also check for the escaped version which might appear in some files
find /usr/share/nginx/html -type f -name "*.js" -exec grep -l "\"KANEO_API_URL\"" {} \; | xargs -r sed -i "s#\"KANEO_API_URL\"#\"$KANEO_API_URL\"#g"
- # Replace placeholder in nginx config so /.well-known proxies to the API
- sed -i "s#KANEO_API_URL_PLACEHOLDER#$KANEO_API_URL#g" /etc/nginx/conf.d/default.conf
+ # Build MCP OAuth discovery JSON for nginx to serve at /.well-known
+ BASE_URL=$(echo "$KANEO_API_URL" | sed 's#/api/*$##')
+ PRM_JSON="{\"resource\":\"${BASE_URL}/api/mcp\",\"authorization_servers\":[\"${BASE_URL}/api\"]}"
+ AS_JSON="{\"issuer\":\"${BASE_URL}/api\",\"authorization_endpoint\":\"${BASE_URL}/api/mcp/authorize\",\"token_endpoint\":\"${BASE_URL}/api/mcp/token\",\"registration_endpoint\":\"${BASE_URL}/api/mcp/register\",\"response_types_supported\":[\"code\"],\"grant_types_supported\":[\"authorization_code\"],\"code_challenge_methods_supported\":[\"S256\"],\"token_endpoint_auth_methods_supported\":[\"none\"]}"
+ sed -i "s#MCP_PRM_JSON_PLACEHOLDER#$PRM_JSON#g" /etc/nginx/conf.d/default.conf
+ sed -i "s#MCP_AS_JSON_PLACEHOLDER#$AS_JSON#g" /etc/nginx/conf.d/default.conf
echo "✅ Replaced KANEO_API_URL with $KANEO_API_URL"
else
echo "WARNING: KANEO_API_URL environment variable is not set. API calls may fail."
- # Replace proxy block with 404 so nginx doesn't fail on missing upstream
- sed -i 's#proxy_pass KANEO_API_URL_PLACEHOLDER;#return 404;#g' /etc/nginx/conf.d/default.conf
- sed -i '/proxy_set_header.*Host/d;/proxy_set_header.*Forwarded/d' /etc/nginx/conf.d/default.conf
+ # No API URL — remove MCP placeholders so nginx doesn't serve broken JSON
+ sed -i "s#MCP_PRM_JSON_PLACEHOLDER#{}#g" /etc/nginx/conf.d/default.conf
+ sed -i "s#MCP_AS_JSON_PLACEHOLDER#{}#g" /etc/nginx/conf.d/default.conf
fi
# Process KANEO_CLIENT_URL efficiently
diff --git a/apps/web/nginx.conf b/apps/web/nginx.conf
index 86595b929..ff2e0af1c 100644
--- a/apps/web/nginx.conf
+++ b/apps/web/nginx.conf
@@ -16,10 +16,18 @@ server {
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 6;
+ location = /.well-known/oauth-protected-resource/api/mcp {
+ default_type application/json;
+ return 200 'MCP_PRM_JSON_PLACEHOLDER';
+ }
+
+ location = /.well-known/oauth-authorization-server/api {
+ default_type application/json;
+ return 200 'MCP_AS_JSON_PLACEHOLDER';
+ }
+
location /.well-known/ {
- proxy_pass KANEO_API_URL_PLACEHOLDER;
- proxy_set_header Host $host;
- proxy_set_header X-Forwarded-Proto $scheme;
+ return 404;
}
# Root location