Skip to content Skip to sidebar Skip to footer

How To Do In Angular2: $httpprovider.defaults.headers.common = {}

I have this code: client (angular2) hosted on this url: http://localhost:8080/Me/html/pages/gasolina/country/USA code: return this.http .post(this.supporToolSaveUrl,

Solution 1:

Your java server has CORS requests disabled. Changing your requests on the client side will not work, because OPTIONS requests are automatically created when requesting a server on another URL (even if it's just a different port on localhost). There's no way you can get around this.

Instead, you should enable CORS on your java server. Here's a tutorial for java jersey that also goes into details about what CORS is.

Post a Comment for "How To Do In Angular2: $httpprovider.defaults.headers.common = {}"