Atlaslog
Atlaslog / Field Notes / Services & tile access
Field note · Services & tile access

CORS preflight rejected: GET passes but POST does not

Quick answer

Tile requests work but submitting an analysis job fails. Because of Content-Type: application/json or an Authorization header the browser sends an OPTIONS preflight, and the backend answers 405 with Allow listing only GET, HEAD and POST.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: GeoServer 2.25 · Nginx 1.24
Symptom
Checklist
  1. Filter the network panel by OPTIONS and read the status and headers.
  2. Check whether the request really needs credentials or custom headers.
  3. Reproduce the preflight with curl, sending Origin, Access-Control-Request-Method and Access-Control-Request-Headers, to rule out browser caching.
  4. Check whether the server sends a wildcard origin together with Allow-Credentials true.
  5. Confirm the preflight reply carries the headers even on a 4xx status, which needs the always flag.
Fix

Answer OPTIONS at the Nginx layer with 204 and Access-Control-Allow-Origin, Allow-Methods GET, POST, PUT, DELETE, OPTIONS, Allow-Headers Content-Type, Authorization, X-Requested-With and Max-Age 86400, all marked always. If credentials are unnecessary, drop credentials include from the fetch so no preflight is sent.

Code
Access to fetch at 'https://gis.example.cn/geoserver/rest/process' from origin
'https://app.example.cn' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
curl -i -X OPTIONS "https://gis.example.cn/geoserver/rest/process" \
  -H "Origin: https://app.example.cn" \
  -H "Access-Control-Request-Method: POST" \
  -H "Access-Control-Request-Headers: content-type,authorization"
Watch out
All 120 field notesChinese originalRunnable examples
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Cite this page

Atlaslog (2026). CORS preflight rejected: GET passes but POST does not. https://www.jingweizhi.com/en/cookbook/wms-cors-preflight.html (accessed 2026-11-03).