Pregunta

I am trying to develop a client/server app with AngluarJS & PHP (which is probably AJAX as it just handles HTTP GET and never actually displays a page in a browser).

I use XAMPP Apache for my localhost and develop the client in the Brackets IDE. Brackets runs a "live preview" on local host port 49883.

[Update] It chooses a new port after each reboot, so if I want to align my Apache with that, then i have manually edit the config after each reboot (ick).

When I try to $http.get('http://127.0.0.1/my_script.php?action=overview_map&date=2014-04-12&user=abc')

the debug console shows.

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:49833' is therefore not allowed access.

How can I get around this?

I put this line in my Windows hosts file 127.0.0.1 test_site and this in my PHP
header('Access-Control-Allow-Origin: test_site' but I still get The 'Access-Control-Allow-Origin' header contains the invalid value 'test_site'.

Perhaps there is some way to get Brackets to start Chrome with the --disable-web-security option, so as to have no CORS problems at all?

Or another (free) IDE which handles this?

This is all new to me, but there must be many, many, many others out there developing with client & server (preferably with JS & PHP) on localhost. How do you do it?

Thanks in advance for your help.

¿Fue útil?

Solución

You're using different port. It is subject to CORS.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top