angular - Cors enabling on expressJs(Angular2) -
i using code:-
app.use(function(req, res, next) { res.header('access-control-allow-origin', '*'); res.header('access-control-allow-headers', 'origin, x-requested-with, content-type, accept'); next(); }); app.get('/', function(req, res, next) { // handle route }); app.post('/', function(req, res, next) { // handle post route });
to enable cors on angular2 project run on expressjs. placing code in server.ts , \tools\tasks\seed\e2e.ts files see express imported there only. tried keep in app.component.ts none of above has helped me. need not know code enable cors question file should have code enable cors.
Comments
Post a Comment