In my React app, I'm trying to make a GET request from my heroku server to get a list of users:
https:
using the following query:
const sendSearch = fetch('/https://blablabla.heroku.com/users', {credentials: 'same-origin'}) function loadMyUsers(data) { data.json().then((jsonData) => {
However, I get the following error:
Fetch API cannot load https://blablabla.heroku.com/users. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. If an opaque response serves your needs, set the request mode to 'no-cors' to fetch the resource with CORS disabled.
I tried changing the Fetch method to many things similar to:
const sendSearch = fetch('https://blablabla.heroku.com/users',{ method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'mode': 'no-cors' } })
but the problem persists.
How do I make a cross-domain request?
source share