Skip to content

Commit 5bb5d3e

Browse files
authored
Merge pull request #114547 from craigshoemaker/marm-routes-updates
Update routes.json file guidance
2 parents 9f43a71 + d5d6fa1 commit 5bb5d3e

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

articles/static-web-apps/add-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ms.author: wachegha
1313

1414
You can add serverless APIs to Azure Static Web Apps via integration with Azure Functions. This article demonstrates how to add and deploy an API to an Azure Static Web Apps site.
1515

16+
For information about how to secure API routes, refer to the [routing guide](routes.md).
17+
1618
## Prerequisites
1719

1820
- Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free).

articles/static-web-apps/routes.md

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,7 @@ The following table lists the appropriate location to put your _routes.json_ fil
3636

3737
### Angular
3838

39-
Angular apps do not copy files in the _src_ folder to the artifact folder by default. You can point the GitHub Actions workflow directly to your _routes.json_ file via the [`routes_location` workflow customization](github-actions-workflow.md#route-file-location), or you can update the _angular.json_ file to copy the file.
40-
41-
Using the `routes_location` customization is preferred, but you can also use the following steps update the _angular.json_ file.
42-
43-
1. In Visual Studio Code, open the _angular.json_ file
44-
1. Go to the property at:
45-
46-
```schema
47-
projects
48-
└── <ANGULAR_APP_NAME>
49-
└── architect
50-
└── build
51-
└── options
52-
└── assets
53-
```
54-
55-
1. Extend the `assets` array to include the _src/routes.json_ file:
56-
57-
```json
58-
"assets": ["src/favicon.ico", "src/assets", "src/routes.json"],
59-
```
60-
61-
Now Angular is configured to copy the _routes.json_ file to your artifact location when your app builds.
39+
Angular apps do not copy all the files in the _src_ folder to the artifact folder by default. To ensure the _routes.json_ file is copied to the correct location, point the GitHub Actions workflow directly to your _routes.json_ file via the [`routes_location` workflow customization](github-actions-workflow.md#route-file-location).
6240

6341
## Defining routes
6442

@@ -185,7 +163,7 @@ The following table lists the available platform error overrides:
185163

186164
## Example route file
187165

188-
The following example shows how to build route rules in a _routes.json_ file. Some routes use the [_/.auth_ system folder](authentication-authorization.md) that access authentication-related endpoints.
166+
The following example shows how to build route rules for static content and APIs in a _routes.json_ file. Some routes use the [_/.auth_ system folder](authentication-authorization.md) that access authentication-related endpoints.
189167

190168
```json
191169
{
@@ -198,6 +176,10 @@ The following example shows how to build route rules in a _routes.json_ file. So
198176
"route": "/admin/*",
199177
"allowedRoles": ["administrator"]
200178
},
179+
{
180+
"route": "/api/admin",
181+
"allowedRoles": ["administrator"]
182+
},
201183
{
202184
"route": "/customers/contoso",
203185
"allowedRoles": ["administrator", "customers_contoso"]
@@ -243,6 +225,7 @@ The following examples describe what happens when a request matches a rule.
243225
|---------|---------|---------|
244226
| _/profile_ | Authenticated users are served the _/profile/index.html_ file. Unauthenticated users redirected to _/login_. |
245227
| _/admin/reports_ | Authenticated users in the _administrators_ role are served the _/admin/reports/index.html_ file. Authenticated users not in the _administrators_ role are served a 401 error<sup>1</sup>. Unauthenticated users redirected to _/login_. |
228+
| _/api/admin_ | Requests from authenticated users in the _administrators_ role are sent to the API. Authenticated users not in the _administrators_ role and unauthenticated users are served a 401 error. |
246229
| _/customers/contoso_ | Authenticated users who belong to either the _administrators_ or _customers\_contoso_ roles are served the _/customers/contoso/index.html_ file<sup>1</sup>. Authenticated users not in the _administrators_ or _customers\_contoso_ roles are served a 401 error. Unauthenticated users redirected to _/login_. |
247230
| _/login_ | Unauthenticated users are challenged to authenticate with GitHub. |
248231
| _/.auth/login/twitter_ | Authorization with Twitter is disabled. The server responds with a 404 error. |

0 commit comments

Comments
 (0)