What I’m trying to do:
Serve HTTP endpoints at paths starting with /.well-known/ (specifically /.well-known/oauth-authorization-server and /.well-known/openid-configuration) for OAuth 2.0 discovery. These are required by the MCP spec for Claude.ai connector authentication.
What I’ve tried and what’s not working:
Both @anvil.server.route(“/.well-known/oauth-authorization-server”) and @anvil.server.http_endpoint(“/.well-known/oauth-authorization-server”) return “No matching API endpoint” when hit from a browser or external client. It seems Anvil intercepts dot-prefixed paths before they reach server code. Is there any way to serve /.well-known/ paths in a published Anvil app?
Code Sample:
@anvil.server.route("/.well-known/oauth-authorization-server", methods=["GET"], enable_cors=True)
def oauth_server_metadata(**params):
return anvil.server.HttpResponse(200, json.dumps({
"issuer": "https://myapp.com",
"authorization_endpoint": "https://myapp.com/authorize",
"token_endpoint": "https://myapp.com/oauth/token"
}), {"Content-Type": "application/json"})```