How could someone help me with the Cors in nodejs, I am already using the npm of cors but it does not work or I think I am not configuring them in an appropriate way, when consuming other apis that lend themselves to the testing of them it does not happen this problem and the sentences are executed correctly ps I am consuming it in ionic3
const express = require('express');
const app = express();
const cors = require('cors');
const morgan = require('morgan');
const bodyParser = require('body-parser');
//settings
app.set('port', process.env.PORT || 3000);
//middleware
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors())
app.get('/animales', function(req, res, next) {
res.json({ msg: 'This is CORS-enabled for all origins!' })
})
app.listen(80, function() {
console.log('CORS-enabled web server listening on port 80')
})
//routes
require('../routes/userRoutes')(app);
require('../routes/ganaRoutes')(app);
app.listen(app.get('port'), () => {
console.log('Server en el puerto 3000');
});