Skip to content

Commit 4e05bdf

Browse files
ochafikclaude
andcommitted
fix(examples): expose mcp-session-id header for CORS requests
Without exposedHeaders in the CORS config, browsers block JavaScript from reading the mcp-session-id response header. This caused the SDK's StreamableHTTPClientTransport to never capture the session ID, breaking all subsequent requests with "Bad request: not initialized" errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 929898f commit 4e05bdf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/shared/server-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export async function startServer(
4242

4343
// Express app - bind to all interfaces for development/testing
4444
const app = createMcpExpressApp({ host: "0.0.0.0" });
45-
app.use(cors());
45+
app.use(cors({
46+
exposedHeaders: ["mcp-session-id"],
47+
}));
4648

4749
// Streamable HTTP (stateful)
4850
app.all("/mcp", async (req: Request, res: Response) => {

0 commit comments

Comments
 (0)