K
K
kutase2015-05-06 19:54:33
Node.js
kutase, 2015-05-06 19:54:33

How to make cross domain requests on node.js?

My project is based on django. But since django is not suitable for realtime functionality, I had to move it to a second backend to node.js. So, the question is how best to make cross-domain requests for it. There is an option to get confused with socket.io, but there may be simpler options with regular http. Maybe this can be somehow solved on nginx/apache? And yes, I would not want to use jsonp.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Timur Shemsedinov, 2015-05-06
@MarcusAurelius

Add headers:

res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'origin, content-type, accept');

S
sim3x, 2015-05-06
@sim3x

And why do a crossdomain, if you can do everything on one for nginx?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question