MCP Server CORS: The Preflight Problem That Broke My MCP Server 92 Times And How I Fixed It For Good
MCP 서버의 CORS 문제로 인한 92번의 장애와 해결 방법에 대한 이야기.
MCP 서버에서 CORS 및 인증 문제로 인해 92번의 장애를 겪은 작성자가 자신의 경험을 공유합니다. 로컬 환경에서는 문제가 없으나, HTTPS와 Cloudflare/Nginx 적용 후에 특정 OPTIONS 요청이 403 에러로 실패하는 이유를 설명합니다. MCP 클라이언트가 인증 전에 OPTIONS 프리플라이트 요청을 보낸다는 점을 강조하며, 이를 통해 문제를 해결한 방법을 논의합니다.
A story of 92 outages caused by CORS issues on MCP server and how it was resolved.
The author shares their experience of encountering 92 outages on their MCP server due to CORS and authentication issues. While everything worked fine in the local environment, specific OPTIONS requests started failing with a 403 error after deploying with HTTPS and Cloudflare/Nginx. The author emphasizes that MCP clients send OPTIONS preflight requests before authentication, which ultimately led to the problem and details how they resolved it.