Friday, 6 February 2015

Angular fullstack crossdoamin issue

If you use angular fullstack as your front-end, you should have no problem.

But if you just want use it as the back-end to manage your endpoints (let's call it A site), and use another angular site for front-end (let's call it B site), you will have cross-domain issue when you are using B site to access end-points in A site.

The solution is add below code in your server/app.js:

app.all('*', function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type');

No comments:

Post a comment