问题
I've encountered that this does not work on multiple files when working with cross-domain. Anyone have any reason or am I doing something wrong? I was able to have it work on one PHP file (mydomain.com/file1.php
) that I'm accessing from another domain (hisdomain.com
). When I tried to access another PHP (mydomain.com/file2.php
) from the same domain (hisdomain.com
), it won't let me access my scripts in file2.php
, because I already have
header("Access-Control-Allow-Origin: *");
in file1.php
. Is this coincidence? Should this not be the problem?
However, these files is in an actual hosting site. (e.g. mydomain.com
). When I tried working in localhost (http://127.0.0.1/file1.php
and http://127.0.0.1/file2.php
) with hisdomain.com
, file1.php
and file2.php
was working correctly with both having
header("Access-Control-Allow-Origin: *");
来源:https://stackoverflow.com/questions/11717551/access-conrol-allow-origin-on-multiple-files-for-cross-domain