Answer the question
In order to leave comments, you need to log in
Why is nodejs not accepting requests from angular on different ports?
Good afternoon, my node does not accept requests from a client running on a different port.
I installed the headers on the node, angular does not swear:
app.use(function (req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);
});
app.use('http://localhost:3000/', router);
router.get('http://localhost:3000/getLeadList', function(req, res) {
console.log('Пришел запрос');
db.Lead.find({}).then(function(leads) {
console.log(leads);
res.send(leads);
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question