PHP Access-Control-Allow-Origin - CORS - Localhost

Asked

Viewed 1,096 times

0

I am trying to access a localhost application by another application that is also local, but on another IP and port and I can not at all. I have tried every way and always appears the same error:

Xmlhttprequest cannot load http://localhost:8080/suaapp/Ws/Customer/new. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://192.168. 1.4:8100' is therefore not allowed access.

I’m using the Code Igniter in PHP and the application is in Ionic.

  • See if any of these links help: https://www.google.pt/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=codeigniter%20cors

  • 1

    Try to put this at the beginning of your PHP code: header('Access-Control-Allow-Origin: *');

  • Yes. I just tested sending to a server and it worked. What should I do to run localhost? Have some more security?

  • Create a domain entry on hosts, which you can switch to using CORS normally: How to create local domains to test my websites and apps?

  • added in Hosts to direct to phpdev.local:8080 and keeps giving the same CORS error.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.