I have 2 web sites that communicate with REST API on my server side. The main web site has the main domain and the second website has a sub domain. for example www.example.com and www.admin.example.com
i have a REST API on the www.example.com root directory and when the www.example.com address to the API everything is OK, but when www.admin.example.com is trying to address to the API, i get an error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://admin.example.com' is therefore not allowed access.
I have this PHP code line on my RestController.php file:
header("Access-Control-Allow-Origin: *");
I also tried to add to my web.config the following code:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="*" />
<add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, OPTIONS" />
<add name="Access-Control-Max-Age" value="1000" />
</customHeaders>
</httpProtocol>
</system.webServer>
but still i get the the No 'Access-Control-Allow-Origin' header error, or the error "The 'Access-Control-Allow-Origin' header contains multiple values '*, *, but only one is allowed."
i don't know if it's important, but we are using Angular 4 for client side.
Does anyone has an idea what is the problem, is it an IIS issue or PHP issue or even client side issue?
Thank You