Skip to content

Commit 7c374fd

Browse files
Merged the CORS tips
1 parent 3d381df commit 7c374fd

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -570,18 +570,7 @@ app.listen(3000);
570570
```
571571

572572
> [!TIP]
573-
> When using this in a remote environment, make sure to allow the header parameter `mcp-session-id` in CORS. Otherwise, it may result in a `Bad Request: No valid session ID provided` error.
574-
>
575-
> For example, in Node.js you can configure it like this:
576-
>
577-
> ```ts
578-
> app.use(
579-
> cors({
580-
> origin: ['https://your-remote-domain.com, https://your-other-remote-domain.com'],
581-
> exposedHeaders: ['mcp-session-id'],
582-
> allowedHeaders: ['Content-Type', 'mcp-session-id'],
583-
> })
584-
> );
573+
> When using this in a remote environment, make sure to allow the header parameter `mcp-session-id` in CORS. Otherwise, it may result in a `Bad Request: No valid session ID provided` error. Read the following section for examples.
585574
> ```
586575
587576
@@ -594,8 +583,10 @@ import cors from 'cors';
594583
595584
// Add CORS middleware before your MCP routes
596585
app.use(cors({
597-
origin: '*', // Configure appropriately for production
586+
origin: '*', // Configure appropriately for production, for example:
587+
// origin: ['https://your-remote-domain.com, https://your-other-remote-domain.com'],
598588
exposedHeaders: ['Mcp-Session-Id']
589+
allowedHeaders: ['Content-Type', 'mcp-session-id'],
599590
}));
600591
```
601592

0 commit comments

Comments
 (0)