Skip to content

Instantly share code, notes, and snippets.

@mbbx6spp
Last active May 10, 2017 19:48
Show Gist options
  • Select an option

  • Save mbbx6spp/1d605ec70ba76aa9783c7dd1f5b31819 to your computer and use it in GitHub Desktop.

Select an option

Save mbbx6spp/1d605ec70ba76aa9783c7dd1f5b31819 to your computer and use it in GitHub Desktop.
CORs cURL check
#!/usr/bin/env bash
function usage() {
>&2 echo "Usage: $0 SOURCE_URL PROXY_URL"
}
function main() {
local -r source_url="${1}"
local -r proxy_url="${2}"
curl \
--fail \
--silent \
--show-error \
--verbose \
--request OPTIONS \
--header 'Access-Control-Request-Headers: Accept, Content-Type' \
--header 'Access-Control-Request-Method: POST' \
--header "Origin: ${proxy_url}" \
"${source_url}"
}
set -eu
set -o pipefail
if [ "$#" -ne 2 ]; then
usage
exit 1
fi
main "$1" "$2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment