I am getting the error:
XMLHttpRequest cannot load http://localhost:3000/data. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
The client side and server side code are both pretty simple:
Server:
var express = require('express');
var app = express();
app.get('/data', function(req, res){
res.send('hello world');
});
app.listen(3000);
Client:
$(document).ready(function() {
$.get('http://localhost:3000/data', {}, function(data){
$("#demo").html(data);
});
});
I understand this is a very general issue so I searched for the existing question and answers but none of them quite worked for me as far as I have tried. And both Chrome and FF have the same issue. Any suggestions?