I'm getting this error on my React app. "Failed to load https://app-name.herokuapp.com/users/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access."
Code in my Express app
var express = require('express');
var router = express.Router();
router.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, X-Auth-Token, Accept");
next();
}
Code in my Redux fetch call
return dispatch => {
const url = "https://app-name.herokuapp.com/users/";
return fetch(url, {
method: 'GET',
mode: 'cors',
})
.then(handleErrors)
.then(res => res.json())....