When Running my code this error pops up in the console!
XMLHttpRequest cannot load http://api.sportsdatallc.org/mlb-t5/games/2015/04/12/boxscore.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
This is my server.js file
var express = require('express');
var app = express();
app.use(express.static('public'));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var server = app.listen(process.env.PORT || 3000, function (){
console.log('### Server is listening on PORT: ', server.address().port);
});
I did some research and it showed used this line but im confused on where i put the express.static line also!
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});