Ionic V4 Http request with origin http://localhost:8080

Hi there!

I am having an issue, calling the REST endpoint with origin “http://localhost:8080” placed in the header instead of the “file://” or whatever else that could omit the CORS request. I am not using the HTTP native plugin but Angular’s HttpClient which is probably the cause of this issue right?
So what are the solutions here?
Is the best solution, using the HTTP native plugin and wrap it into the Observable for example? It bothers me because it’s built with promises basically. And I think the testing of the app would be simpler, using HttpClient from Angular. Am I wrong?

Thanks in advance!


I’ve written an article summing up the options for dealing with CORS:

In short, the best solution is to modify the server to include the appropriate header to allow the origin you are making the request from (or all origins if you want). The second best option is probably either using native HTTP or proxying the request through a server you control - depending on your circumstances.

1 Like

Ok so using HTTP native plugin doesn’t seem like the best option. Ok we will change the server config.