domfarolino / angular2-login-seed

(deprecated) Seed app w/ Angular2, Node, Express, and OAuth login
https://domfarolino.com/angular2-login-seed
MIT License
181 stars 77 forks source link

Access-Control-Allow-Origin #18

Closed cissecedric closed 7 years ago

cissecedric commented 7 years ago

Hi,

I deployed, angular2-login-seed on heroku , and I don't understand why I get this when I try to registera new user :

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 503

I have kept this part of the code : const allowedOrigins = ['http://127.0.0.1:4200','http://localhost:4200', 'https://xxxxxxxx.herokuapp.com'];

router.use(function(request, response, next) { var origin = request.headers.origin; if (allowedOrigins.indexOf(origin) > -1) { response.setHeader('Access-Control-Allow-Origin', origin); } response.setHeader('Access-Control-Allow-Headers', 'Content-Type,X-Requested-With'); response.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,HEAD,DELETE,OPTIONS'); response.setHeader('Access-Control-Allow-Credentials', true); next(); });

It doesn't seem to be enough, do you have any idea ? Regards,