Skip to content

Commit 2a0595c

Browse files
committed
feat: add the MDN link for CORS with credentials
1 parent b92129e commit 2a0595c

File tree

3 files changed

+96
-85
lines changed

3 files changed

+96
-85
lines changed

.vscode/launch.json

Lines changed: 84 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,86 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"type": "node",
6-
"request": "launch",
7-
"name": "Run apollo-mcp-server [Weather][Streamable HTTP]",
8-
"runtimeExecutable": "cargo",
9-
"runtimeArgs": [
10-
"run",
11-
"--bin",
12-
"apollo-mcp-server",
13-
"--",
14-
"graphql/weather/config.yaml",
15-
],
16-
"cwd": "${workspaceFolder}",
17-
"console": "integratedTerminal",
18-
"env": {
19-
"RUST_BACKTRACE": "1"
20-
}
21-
},
22-
{
23-
"type": "lldb",
24-
"request": "launch",
25-
"name": "Debug apollo-mcp-server [Weather][Streamable HTTP]",
26-
"cargo": {
27-
"args": [
28-
"build",
29-
"--bin=apollo-mcp-server",
30-
"--lib"
31-
],
32-
"filter": {
33-
"name": "apollo-mcp-server",
34-
"kind": "bin"
35-
}
36-
},
37-
"args": [
38-
"graphql/weather/config.yaml",
39-
],
40-
"cwd": "${workspaceFolder}",
41-
"env": {
42-
"RUST_BACKTRACE": "1"
43-
}
44-
},
45-
{
46-
"type": "node",
47-
"request": "launch",
48-
"name": "Run apollo-mcp-server [TheSpaceDevs][Streamable HTTP]",
49-
"runtimeExecutable": "cargo",
50-
"runtimeArgs": [
51-
"run",
52-
"--bin",
53-
"apollo-mcp-server",
54-
"--",
55-
"graphql/TheSpaceDevs/config.yaml",
56-
],
57-
"cwd": "${workspaceFolder}",
58-
"console": "integratedTerminal",
59-
"env": {
60-
"RUST_BACKTRACE": "1"
61-
}
62-
},
63-
{
64-
"type": "node",
65-
"request": "launch",
66-
"name": "Run mcp-inspector",
67-
"runtimeExecutable": "npx",
68-
"runtimeArgs": [
69-
"@modelcontextprotocol/inspector"
70-
],
71-
"cwd": "${workspaceFolder}",
72-
"console": "integratedTerminal"
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Run apollo-mcp-server [Weather][Streamable HTTP]",
8+
"runtimeExecutable": "cargo",
9+
"runtimeArgs": [
10+
"run",
11+
"--bin",
12+
"apollo-mcp-server",
13+
"--",
14+
"graphql/weather/config.yaml"
15+
],
16+
"cwd": "${workspaceFolder}",
17+
"console": "integratedTerminal",
18+
"env": {
19+
"RUST_BACKTRACE": "1"
20+
}
21+
},
22+
{
23+
"type": "lldb",
24+
"request": "launch",
25+
"name": "Debug apollo-mcp-server [Weather][Streamable HTTP]",
26+
"cargo": {
27+
"args": ["build", "--bin=apollo-mcp-server", "--lib"],
28+
"filter": {
29+
"name": "apollo-mcp-server",
30+
"kind": "bin"
7331
}
74-
]
75-
}
32+
},
33+
"args": ["graphql/weather/config.yaml"],
34+
"cwd": "${workspaceFolder}",
35+
"env": {
36+
"RUST_BACKTRACE": "1",
37+
"APOLLO_MCP_LOGGING__LEVEL": "debug"
38+
}
39+
},
40+
{
41+
"type": "node",
42+
"request": "launch",
43+
"name": "Run apollo-mcp-server [TheSpaceDevs][Streamable HTTP]",
44+
"runtimeExecutable": "cargo",
45+
"runtimeArgs": [
46+
"run",
47+
"--bin",
48+
"apollo-mcp-server",
49+
"--",
50+
"graphql/TheSpaceDevs/config.yaml"
51+
],
52+
"cwd": "${workspaceFolder}",
53+
"console": "integratedTerminal",
54+
"env": {
55+
"RUST_BACKTRACE": "1"
56+
}
57+
},
58+
{
59+
"type": "lldb",
60+
"request": "launch",
61+
"name": "Debug apollo-mcp-server [TheSpaceDevs][Streamable HTTP]",
62+
"cargo": {
63+
"args": ["build", "--bin=apollo-mcp-server", "--lib"],
64+
"filter": {
65+
"name": "apollo-mcp-server",
66+
"kind": "bin"
67+
}
68+
},
69+
"args": ["graphql/TheSpaceDevs/config.yaml"],
70+
"cwd": "${workspaceFolder}",
71+
"env": {
72+
"RUST_BACKTRACE": "1",
73+
"APOLLO_MCP_LOGGING__LEVEL": "debug"
74+
}
75+
},
76+
{
77+
"type": "node",
78+
"request": "launch",
79+
"name": "Run mcp-inspector",
80+
"runtimeExecutable": "npx",
81+
"runtimeArgs": ["@modelcontextprotocol/inspector"],
82+
"cwd": "${workspaceFolder}",
83+
"console": "integratedTerminal"
84+
}
85+
]
86+
}

crates/apollo-mcp-server/src/cors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl CorsConfig {
181181
// Cannot use credentials with any origin
182182
if self.allow_credentials && self.allow_any_origin {
183183
return Err(ServerError::Cors(
184-
"Cannot use allow_credentials with allow_any_origin for security reasons"
184+
"Cannot use allow_credentials with allow_any_origin for security reasons. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS#requests_with_credentials"
185185
.to_string(),
186186
));
187187
}

docs/source/cors.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Configuring CORS
33
---
44

5-
# Configuring CORS
5+
## Configuring CORS
66

77
Control browser access to your MCP server
88

@@ -58,7 +58,7 @@ cors:
5858

5959
If your MCP server serves exclusively _non_-browser-based clients, you probably don't need to enable CORS configuration.
6060

61-
## Passing credentials
61+
### Passing credentials
6262

6363
If your MCP server requires requests to include a user's credentials (e.g., via cookies), you need to modify your CORS configuration to tell the browser those credentials are allowed.
6464

@@ -76,7 +76,7 @@ cors:
7676

7777
**To support credentialed requests, your server's config file must specify individual `origins` or `match_origins`**. If your server enables `allow_any_origin`, your browser will refuse to send credentials.
7878

79-
## All `cors` options
79+
### All `cors` options
8080

8181
The following snippet shows all CORS configuration defaults for Apollo MCP Server:
8282

@@ -134,11 +134,11 @@ cors:
134134
max_age: 7200 # 2 hours
135135
```
136136
137-
## Origin matching
137+
### Origin matching
138138
139139
Apollo MCP Server supports two types of origin matching:
140140
141-
### Exact origins
141+
#### Exact origins
142142
143143
Use the `origins` array for exact origin matches:
144144

@@ -150,7 +150,7 @@ cors:
150150
- https://myapp.example.com
151151
```
152152

153-
### Pattern matching
153+
#### Pattern matching
154154

155155
Use the `match_origins` array for regex pattern matching:
156156

@@ -163,9 +163,9 @@ cors:
163163
- "^https://.*\\.example\\.com$" # Any subdomain of example.com
164164
```
165165

166-
## Common configurations
166+
### Common configurations
167167

168-
### Development setup
168+
#### Development setup
169169

170170
For local development with hot reloading and various ports:
171171

@@ -177,7 +177,7 @@ cors:
177177
allow_credentials: true
178178
```
179179

180-
### Production setup
180+
#### Production setup
181181

182182
For production with specific known origins:
183183

@@ -190,7 +190,7 @@ cors:
190190
max_age: 86400 # 24 hours
191191
```
192192

193-
### Public API setup
193+
#### Public API setup
194194

195195
For public APIs that don't require credentials:
196196

@@ -201,7 +201,7 @@ cors:
201201
allow_credentials: false # Cannot use credentials with any origin
202202
```
203203

204-
## Browser integration example
204+
### Browser integration example
205205

206206
Here's a simple example of connecting to Apollo MCP Server from a browser:
207207

0 commit comments

Comments
 (0)