Skip to content

Instantly share code, notes, and snippets.

@morales2k morales2k/.profile

Last active Nov 6, 2019
Embed
What would you like to do?
Little bash script you can pass args to and test cors headers with.
#same functionality in a bash profile function
function cors-test() {
ORIGIN=$1
URI=$2
METHOD=$3
if [ -z "$3" ] && [ -z "$METHOD" ]; then
echo -e "\033[0;33mSince you did not provide a method, the default GET will be used.\nYou can provide a third param to specify the method\n(to use with the curl -X option).\033[1;33m\033[0m\n"
METHOD="-X ${METHOD}"
fi
if [ -n "$ORIGIN" ] && [ -n "$URI" ]; then
curl ${METHOD} -H "Origin: ${ORIGIN}" --verbose "${URI}"
else
echo -e "\033[1;31mWhoops!\n\nYou need to provide at least two parameters.\n\nFirst argument: The origin domain to mock a curl call from.\n\nSecond argument, the url to hit with this cURL call to test CORS rules.\033[1;31m\033[0m\n"
fi
}
#!/bin/bash
ORIGIN=$1
URI=$2
METHOD=$3
if [ -z "$3" ] && [ -z "$METHOD" ]; then
echo -e "\033[0;33mSince you did not provide a method, the default GET will be used.\nYou can provide a third param to specify the method\n(to use with the curl -X option).\033[1;33m\033[0m\n"
METHOD="-X ${METHOD}"
fi
if [ -n "$ORIGIN" ] && [ -n "$URI" ]; then
curl ${METHOD} -H "Origin: ${ORIGIN}" --verbose "${URI}"
else
echo -e "\033[1;31mWhoops!\n\nYou need to provide at least two parameters.\n\nFirst argument: The origin domain to mock a curl call from.\n\nSecond argument, the url to hit with this cURL call to test CORS rules.\033[1;31m\033[0m\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.