# CORS 配置:允许游戏前端访问配置 API # 将此配置添加到 mini-chat.1024tool.vip 的 Nginx 配置中 location /api/internal/game/minesweeper/config { # OPTIONS 预检请求处理 if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' 'https://game.1024tool.vip' always; add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'X-Internal-Key, Content-Type, Accept' always; add_header 'Access-Control-Max-Age' 3600; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } # 实际请求的 CORS 头 add_header 'Access-Control-Allow-Origin' 'https://game.1024tool.vip' always; add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'X-Internal-Key, Content-Type, Accept' always; # 反向代理到后端服务 proxy_pass http://127.0.0.1:9991; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }