# 仅在你必须跨域直连接口(不做同源反代)时使用: # 将以下内容放到 clinic-api.websoft.top 的 nginx server{} / location{} 中。 # # 注意: # - 建议把 allow-origin 固定到你的前端域名,避免使用 *。 # - 如果你使用 cookie(withCredentials),还需要加 Access-Control-Allow-Credentials: true, # 并且 allow-origin 不能是 *。 location /api/ { # 预检请求 if ($request_method = OPTIONS) { add_header Access-Control-Allow-Origin https://clinic.websoft.top always; add_header Access-Control-Allow-Methods "GET,POST,PUT,DELETE,PATCH,OPTIONS" always; add_header Access-Control-Allow-Headers "Authorization,Content-Type,TenantId,X-Requested-With" always; add_header Access-Control-Max-Age 86400 always; add_header Content-Length 0; add_header Content-Type text/plain; return 204; } add_header Access-Control-Allow-Origin https://clinic.websoft.top always; add_header Access-Control-Expose-Headers Authorization always; add_header Vary Origin always; proxy_http_version 1.1; 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; # TODO: 替换为真实 upstream proxy_pass http://127.0.0.1:9013; }