Skip to content

Instantly share code, notes, and snippets.

@l0co
Created April 23, 2020 10:40
Show Gist options
  • Select an option

  • Save l0co/5826ba79e1e02f9a2f1f1c50516664d7 to your computer and use it in GitHub Desktop.

Select an option

Save l0co/5826ba79e1e02f9a2f1f1c50516664d7 to your computer and use it in GitHub Desktop.
Simple script to test if CORS works from the browser
<script>
for (let method of ['GET', 'POST']) {
fetch('http://example.com', {method}).then(e => {
document.write('<p>' + method + ' succeded with result: ' + e + '</p>')
console.log(e)
}).catch(e => {
document.write('<p>' + method + ' failed due to: ' + e + '</p>')
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment