mcp
This commit is contained in:
@@ -65,13 +65,15 @@ export class McpServerService {
|
||||
return;
|
||||
}
|
||||
|
||||
const pathname = new URL(request.url ?? '/', 'http://localhost').pathname;
|
||||
if (pathname !== '/mcp') {
|
||||
const url = new URL(request.url ?? '/', 'http://localhost');
|
||||
if (!['/mcp', '/mcp/', '/api/mcp', '/api/mcp/'].includes(url.pathname)) {
|
||||
response.writeHead(404, { 'content-type': 'application/json' });
|
||||
response.end(JSON.stringify({ error: 'Not found' }));
|
||||
return;
|
||||
}
|
||||
|
||||
request.url = `/mcp${url.search}`;
|
||||
|
||||
if (!this.isAuthorized(request)) {
|
||||
response.writeHead(401, { 'content-type': 'application/json' });
|
||||
response.end(JSON.stringify({ error: 'Unauthorized' }));
|
||||
|
||||
@@ -33,7 +33,7 @@ server {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
}
|
||||
|
||||
location = /mcp {
|
||||
location ~ ^/(api/)?mcp/?$ {
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
@@ -43,6 +43,7 @@ server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Prefix /mcp;
|
||||
proxy_pass http://127.0.0.1:3001;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user