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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -