Serving /.well-known/ paths with @anvil.server.route — is it possible?

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"})``` 

You’re in luck! There’s an undocumented but fully functional decorator mentioned in a previous forum post. Simply use @anvil.server.wellknown_endpoint("/oauth-authorization-server")

2 Likes

Long story short: This should work, and it will do shortly! Moved to Bug Reports – but yes, the @wellknown_endpoint() workaround is the right choice in the meantime.

3 Likes

This worked!! Thanks so much!!