Skip to content

Commit cf9767b

Browse files
Add placeholder for CORS
Resolves #27
1 parent c4a2572 commit cf9767b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

shared/apim-policies/all-apis.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
This is the global All APIs policy.
3+
If you want to apply CORS policies to all APIs, uncomment the CORS policy block below and make the necessary adjustments to the allowed origins.
4+
-->
5+
<policies>
6+
<inbound>
7+
<!--
8+
<cors allow-credentials="true" terminate-unmatched-request="false">
9+
<allowed-origins>
10+
<origin>[ADD YOUR ORIGINS]</origin>
11+
</allowed-origins>
12+
<allowed-methods preflight-result-max-age="300">
13+
<method>*</method>
14+
</allowed-methods>
15+
<allowed-headers>
16+
<header>*</header>
17+
</allowed-headers>
18+
<expose-headers>
19+
<header>*</header>
20+
</expose-headers>
21+
</cors>
22+
-->
23+
</inbound>
24+
<backend>
25+
<forward-request />
26+
</backend>
27+
<outbound />
28+
<on-error />
29+
</policies>

shared/bicep/modules/apim/v1/apim.bicep

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,21 @@ param apimManagedIdentityType string = 'SystemAssigned'
6767
param apimUserAssignedManagedIdentityId string = ''
6868

6969

70+
@description('Content of the global All APIs policy XML. If provided, sets the global policy.')
71+
param globalPolicyXml string = loadTextContent('../../../../apim-policies/all-apis.xml')
72+
7073
// ------------------------------
7174
// RESOURCES
7275
// ------------------------------
76+
// https://learn.microsoft.com/azure/templates/microsoft.apimanagement/service/policies
77+
resource apimGlobalPolicy 'Microsoft.ApiManagement/service/policies@2024-06-01-preview' = if (!empty(globalPolicyXml)) {
78+
name: 'policy'
79+
parent: apimService
80+
properties: {
81+
format: 'xml'
82+
value: globalPolicyXml
83+
}
84+
}
7385

7486
// https://learn.microsoft.com/azure/templates/microsoft.apimanagement/service
7587
resource apimService 'Microsoft.ApiManagement/service@2024-06-01-preview' = {

0 commit comments

Comments
 (0)