Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1529

Making a HTTP request from a static web page - blocked by CORS policy

$
0
0

I simply want to make a GET request to jsonbin.io from a static web page. I have used postman to successfully make the request but when I attempt the HTTP request on my web page I keep getting the below error (I have attempted hosting the page using localhost and github pages):

Access to XMLHttpRequest at 'https://api.jsonbin.io/v3/b/67f8c9fd8a456b7966871939/latest' from origin 'https://michael-hello.github.io' 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.

My test code is very simple and uses axios:

import axios from 'axios'axios.get('https://api.jsonbin.io/v3/b/___/latest', {    headers: {"X-Access-Key": "___",    }}).then((response) => {    console.log(response)});

I'm going around in circles trying to figure this out and having no luck. I think the issue is caused due to the CORS preflight being triggered but I don't know how to prevent that. Any help much appreicated.


Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>