Jeremiah Lowin Claude commited on
Commit
72d793f
·
1 Parent(s): 5d876b5

Fix CORS documentation example to properly handle preflight requests

Browse files

The previous example only allowed GET methods, causing browser preflight
requests to fail with "Disallowed CORS method" errors. Updated to include
the required parameters for proper CORS support with MCP clients.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (2) hide show
  1. CLAUDE.md +6 -1
  2. docs/deployment/asgi.mdx +7 -1
CLAUDE.md CHANGED
@@ -27,4 +27,9 @@ Only use HTTP transport when testing network-specific features. Prefer Streamabl
27
  # Only when network testing is required
28
  async with Client(transport=StreamableHttpTransport(server_url)) as client:
29
  result = await client.ping()
30
- ```
 
 
 
 
 
 
27
  # Only when network testing is required
28
  async with Client(transport=StreamableHttpTransport(server_url)) as client:
29
  result = await client.ping()
30
+ ```
31
+
32
+ ## Development Workflow
33
+
34
+ - You must always run pre-commit if you open a PR, because it is run as part of a required check.
35
+ - When opening PRs, apply labels appropriately for bugs/breaking changes/enhancements/features. Generally, improvements are enhancements (not features) unless told otherwise.
docs/deployment/asgi.mdx CHANGED
@@ -96,7 +96,13 @@ mcp = FastMCP("MyServer")
96
 
97
  # Define custom middleware
98
  custom_middleware = [
99
- Middleware(CORSMiddleware, allow_origins=["*"]),
 
 
 
 
 
 
100
  ]
101
 
102
  # Create ASGI app with custom middleware
 
96
 
97
  # Define custom middleware
98
  custom_middleware = [
99
+ Middleware(
100
+ CORSMiddleware,
101
+ allow_origins=["https://example.com", "https://app.example.com"],
102
+ allow_credentials=True,
103
+ allow_methods=["GET", "POST", "OPTIONS"],
104
+ allow_headers=["Content-Type", "Authorization"],
105
+ ),
106
  ]
107
 
108
  # Create ASGI app with custom middleware