Skip to content

Instantly share code, notes, and snippets.

@exAspArk
Last active May 1, 2024 03:59
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 14 You must be signed in to fork a gist
  • Save exAspArk/07bbbafa2a9171b6c260989780cc0955 to your computer and use it in GitHub Desktop.
Save exAspArk/07bbbafa2a9171b6c260989780cc0955 to your computer and use it in GitHub Desktop.
Test CORS with cURL
curl -I -X OPTIONS \
-H "Origin: http://EXAMPLE.COM" \
-H 'Access-Control-Request-Method: GET' \
http://EXAMPLE.COM/SOMETHING 2>&1 | grep 'Access-Control-Allow-Origin'
@thinhlh
Copy link

thinhlh commented Apr 26, 2023

Better use a case insensitive grep:

MY_URL=http://EXAMPLE.COM

curl -I -X OPTIONS \
  -H "Origin: ${MY_URL}" \
  -H 'Access-Control-Request-Method: GET' \
  "${MY_URL}/SOMETHING" 2>&1 | grep -i 'Access-Control-Allow-Origin'

This one works for me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment