I have a setup involving
Frontend server (Node.js, domain: localhost:3000) <---> Backend (Django, Ajax, domain: localhost:8000)
Browser <-- webapp <
If you are using express you can use the cors package to allow CORS like so instead of writing your middleware;
express
var express = require('express') , cors = require('cors') , app = express(); app.use(cors()); app.get(function(req,res){ res.send('hello'); });