Ionic3 - Cross origin requests are only supported for HTTP

Create an application with back-end spring-rest and front-end with Ionic3. It’s working locally. So I put the backend on the Amazon ec2. I am getting access to end-points through Postman or the browser itself, but I can not access through the front-end. It returns the following information: “Cross origin requests are only supported for HTTP.” and a second information “[Error] XMLHttpRequest can not load due to access control checks.”. How can I resolve this? thanks.

header(‘Access-Control-Allow-Origin: *’);
add this in your api

Hi, I already did this action, I can actually run the endpoint through the browser or Postman, only in the app that brings this error. “Cross origin requests are only supported for HTTP.” For exemple, this link run fine.
“XMLHttpRequest cannot load due to access control checks.”

Check this article, it may help you find what’s happening: CORS Errors in Ionic Apps.

Also, what origin is your app running from?


1 Like

Hello, I made the correction, in fact the error was in the URL, I had not informed the http: // at the beginning. Great article, quite enlightening. Thank you.

1 Like

if you using ionic 4 , use ionic-native HTTP allow cross-origin but you need to run your app in device,other wise handle through your back end code.

1 Like