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 ec2-52-67-72-74.sa-east-1.compute.amazonaws.com:8080/login due to access control checks.”. How can I resolve this? thanks.
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 ec2-52-67-74-76.sa-east-1.compute.amazonaws.com:8080/login 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?
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.
if you using ionic 4 , use ionic-native HTTP plugin.it allow cross-origin but you need to run your app in device,other wise handle through your back end code.