I have one site that works like cdn for my other sites.
I added the following to web.config
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,PUT,DELETE" />
<add name="Arr-Disable-Session-Affinity" value="True" />
</customHeaders>
</httpProtocol>
<rewrite>
<outboundRules>
<clear />
<rule name="AddCrossDomainHeader">
<match serverVariable="RESPONSE_Access_Control_Allow_Origin" pattern=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTP_ORIGIN}" pattern="(http(s)?://((.+\.)?[a-zA-Z0-9-]*\.ap\.dk|(.+\.)?localhost\:[0-9]*))" />
</conditions>
<action type="Rewrite" value="{C:0}" />
</rule>
</outboundRules>
</rewrite>
I was inspired by answer No. 2 here Access-control-allow-origin with multiple domains
But rewriting Access_Control_Allow_Origin only works on localhost. On a live site, this is not overwritten, and then I get an error message:
Failed to load https://aptestlogin.ap.dk//Widgets/Footer.html : the header 'Access-Control-Allow-Origin' has a value of ' https://aptestproject.ap.dk ', which is not equal to the specified start. Origin ' https://aptestcompany.ap.dk ', therefore access is not allowed
"Footer.html", , , .