Skip to content

Commit ea654e2

Browse files
Merge pull request #267354 from craigshoemaker/swa/configure
[Static Web Apps] Update: Configuration (freshness)
2 parents 60bdeca + f3a016a commit ea654e2

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

articles/static-web-apps/configuration.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ You can define configuration for Azure Static Web Apps in the _staticwebapp.conf
2626
> [!NOTE]
2727
> [_routes.json_](https://github.com/Azure/static-web-apps/wiki/routes.json-reference-(deprecated)) that was previously used to configure routing is deprecated. Use _staticwebapp.config.json_ as described in this article to configure routing and other settings for your static web app.
2828
>
29-
> This document is regarding Azure Static Web Apps, which is a standalone product and separate from the [static website hosting](../storage/blobs/storage-blob-static-website.md) feature of Azure Storage.
29+
> This document describes how to configure Azure Static Web Apps, which is a standalone product and separate from the [static website hosting](../storage/blobs/storage-blob-static-website.md) feature of Azure Storage.
3030
3131
## File location
3232

33-
The recommended location for the _staticwebapp.config.json_ is in the folder set as the `app_location` in the [workflow file](./build-configuration.md). However, the file may be placed in any subfolder within the folder set as the `app_location`. Additionally, if there is a build step, you must ensure that the build step outputs the file to the root of the output_location.
33+
The recommended location for the _staticwebapp.config.json_ is in the folder set as the `app_location` in the [workflow file](./build-configuration.md). However, you can place the file in any subfolder within the folder set as the `app_location`. Additionally, if there's a build step, you must ensure that the build step outputs the file to the root of the output_location.
3434

3535
See the [example configuration](#example-configuration-file) file for details.
3636

@@ -94,7 +94,7 @@ This rule matches requests for the file _/profile/index.html_. Because _index.ht
9494
9595
#### <a name="wildcards"></a>Wildcard pattern
9696

97-
Wildcard rules match all requests in a route pattern, are only supported at the end of a path, and may be filtered by file extension. See the [example configuration file](#example-configuration-file) for usage examples.
97+
Wildcard rules match all requests in a route pattern, and are only supported at the end of a path. See the [example configuration file](#example-configuration-file) for usage examples.
9898

9999
For instance, to implement routes for a calendar application, you can rewrite all URLs that fall under the _calendar_ route to serve a single file.
100100

@@ -173,7 +173,7 @@ You can create new roles as needed in the `allowedRoles` array. To restrict a ro
173173
174174
#### Restrict access to entire application
175175

176-
It's common to require authentication for every route in an application. To enable this, add a rule that matches all routes and include the built-in `authenticated` role in the `allowedRoles` array.
176+
You'll often want to require authentication for every route in your application. To lock down your routes, add a rule that matches all routes and include the built-in `authenticated` role in the `allowedRoles` array.
177177

178178
The following example configuration blocks anonymous access and redirects all unauthenticated users to the Microsoft Entra sign-in page.
179179

@@ -199,7 +199,7 @@ The following example configuration blocks anonymous access and redirects all un
199199
200200
## Fallback routes
201201

202-
Single Page Applications often rely on client-side routing. These client-side routing rules update the browser's window location without making requests back to the server. If you refresh the page, or go directly to URLs generated by client-side routing rules, a server-side fallback route is required to serve the appropriate HTML page, which is generally the _index.html_ for your client-side app.
202+
Single Page Applications often rely on client-side routing. These client-side routing rules update the browser's window location without making requests back to the server. If you refresh the page, or go directly to URLs generated by client-side routing rules, a server-side fallback route is required to serve the appropriate HTML page. The fallback page is often designated as _index.html_ for your client-side app.
203203

204204
You can define a fallback rule by adding a `navigationFallback` section. The following example returns _/index.html_ for all static file requests that don't match a deployed file.
205205

@@ -222,7 +222,7 @@ You can control which requests return the fallback file by defining a filter. In
222222
}
223223
```
224224

225-
For example, with the directory structure below, the above navigation fallback rule would result in the outcomes detailed in the table below.
225+
For example, with the following directory structure, the above navigation fallback rule would result in the outcomes detailed in the followingtable.
226226

227227
```files
228228
├── images
@@ -238,13 +238,13 @@ For example, with the directory structure below, the above navigation fallback r
238238

239239
| Requests to... | returns... | with the status... |
240240
|--|--|--|
241-
| _/about/_ | The _/index.html_ file | `200` |
242-
| _/images/logo.png_ | The image file | `200` |
243-
| _/images/icon.svg_ | The _/index.html_ file - since the _svg_ file extension isn't listed in the `/images/*.{png,jpg,gif}` filter | `200` |
244-
| _/images/unknown.png_ | File not found error | `404` |
245-
| _/css/unknown.css_ | File not found error | `404` |
246-
| _/css/global.css_ | The stylesheet file | `200` |
247-
| Any other file outside the _/images_ or _/css_ folders | The _/index.html_ file | `200` |
241+
| _/about/_ | The _/index.html_ file. | `200` |
242+
| _/images/logo.png_ | The image file. | `200` |
243+
| _/images/icon.svg_ | The _/index.html_ file - since the _svg_ file extension isn't listed in the `/images/*.{png,jpg,gif}` filter. | `200` |
244+
| _/images/unknown.png_ | File not found error. | `404` |
245+
| _/css/unknown.css_ | File not found error. | `404` |
246+
| _/css/global.css_ | The stylesheet file. | `200` |
247+
| Any other file outside the _/images_ or _/css_ folders | The _/index.html_ file. | `200` |
248248

249249
> [!IMPORTANT]
250250
> If you are migrating from the deprecated [_routes.json_](https://github.com/Azure/static-web-apps/wiki/routes.json-reference-(deprecated)) file, do not include the legacy fallback route (`"route": "/*"`) in the [routing rules](#routes).
@@ -260,9 +260,9 @@ To remove a header, set the value to an empty string (`""`).
260260
Some common use cases for global headers include:
261261

262262
- Custom caching rules
263-
- Enforcing security policies
263+
- Security policies
264264
- Encoding settings
265-
- Configuring cross-origin resource sharing ([CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS))
265+
- Cross-origin resource sharing ([CORS](https://developer.mozilla.org/docs/Web/HTTP/CORS)) configuration
266266

267267
The following example implements a custom CORS configuration.
268268

@@ -354,14 +354,15 @@ In addition to IP address blocks, you can also specify [service tags](../virtual
354354

355355
## Authentication
356356

357-
* [Default authentication providers](authentication-authorization.md#set-up-sign-in), don't require settings in the configuration file.
357+
* [Default authentication providers](authentication-authorization.md#set-up-sign-in) don't require settings in the configuration file.
358+
358359
* [Custom authentication providers](authentication-custom.md) use the `auth` section of the settings file.
359360

360361
For details on how to restrict routes to authenticated users, see [Securing routes with roles](#securing-routes-with-roles).
361362

362363
### Disable cache for authenticated paths
363364

364-
If you set up [manual integration with Azure Front Door](front-door-manual.md), you may want to disable caching for your secured routes. With [enterprise-grade edge](enterprise-edge.md) enabled, this is already configured for you.
365+
If you set up [manual integration with Azure Front Door](front-door-manual.md), you may want to disable caching for your secured routes. With [enterprise-grade edge](enterprise-edge.md) enabled, caching is already disabled for your secured routes.
365366

366367
To disable Azure Front Door caching for secured routes, add `"Cache-Control": "no-store"` to the route header definition.
367368

@@ -379,7 +380,7 @@ For example:
379380

380381
## Forwarding gateway
381382

382-
The `forwardingGateway` section configures how a static web app is accessed from a forwarding gateway such as a CDN or Azure Front Door.
383+
The `forwardingGateway` section configures how a static web app is accessed from a forwarding gateway such as a Content Delivery Network (CDN) or Azure Front Door.
383384

384385
> [!NOTE]
385386
> Forwarding gateway configuration is only available in the Azure Static Web Apps Standard plan.
@@ -422,7 +423,7 @@ For example, the following configuration shows how you can add a unique identifi
422423

423424
## Trailing slash
424425

425-
A trailing slash is the `/` at the end of a URL. Conventionally, trailing slash URL refers to a directory on the web server, while a non-trailing slash indicates a file.
426+
A trailing slash is the `/` at the end of a URL. Conventionally, trailing slash URL refers to a directory on the web server, while a nontrailing slash indicates a file.
426427

427428
Search engines treat the two URLs separately, regardless of whether it's a file or a directory. When the same content is rendered at both of these URLs, your website serves duplicate content, which can negatively affect search engine optimization (SEO). When explicitly configured, Static Web Apps applies a set of URL normalization and redirect rules that help improve your website’s performance and SEO.
428429

@@ -447,7 +448,7 @@ When you're setting `trailingSlash` to `always`, all requests that don't include
447448

448449
### Never
449450

450-
When setting `trailingSlash` to `never`, all requests ending in a trailing slash are redirected to a non-trailing slash URL. For example, `/contact/` is redirected to `/contact`.
451+
When setting `trailingSlash` to `never`, all requests ending in a trailing slash are redirected to a nontrailing slash URL. For example, `/contact/` is redirected to `/contact`.
451452

452453
```json
453454
"trailingSlash": "never"
@@ -464,7 +465,7 @@ When setting `trailingSlash` to `never`, all requests ending in a trailing slash
464465

465466
### Auto
466467

467-
When you set `trailingSlash` to `auto`, all requests to folders are redirected to a URL with a trailing slash. All requests to files are redirected to a non-trailing slash URL.
468+
When you set `trailingSlash` to `auto`, all requests to folders are redirected to a URL with a trailing slash. All requests to files are redirected to a nontrailing slash URL.
468469

469470
```json
470471
"trailingSlash": "auto"
@@ -479,7 +480,7 @@ When you set `trailingSlash` to `auto`, all requests to folders are redirected t
479480
| _/contact/_ | The _/contact.html_ file | `301` | _/contact_ |
480481
| _/contact.html_ | The _/contact.html_ file | `301` | _/contact_ |
481482

482-
For optimal website performance, configure a trailing slash strategy using one of the `always`, `never` or `auto` modes.
483+
For optimal website performance, configure a trailing slash strategy using one of the `always`, `never`, or `auto` modes.
483484

484485
By default, when the `trailingSlash` configuration is omitted, Static Web Apps applies the following rules:
485486

@@ -591,13 +592,13 @@ Based on the above configuration, review the following scenarios.
591592
| _/api/admin_ | `GET` requests from authenticated users in the _registeredusers_ role are sent to the API. Authenticated users not in the _registeredusers_ role and unauthenticated users are served a `401` error.<br/><br/>`POST`, `PUT`, `PATCH`, and `DELETE` requests from authenticated users in the _administrator_ role are sent to the API. Authenticated users not in the _administrator_ role and unauthenticated users are served a `401` error. |
592593
| _/customers/contoso_ | Authenticated users who belong to either the _administrator_ or _customers_contoso_ roles are served the _/customers/contoso/index.html_ file. Authenticated users not in the _administrator_ or _customers_contoso_ roles are served a `403` error<sup>1</sup>. Unauthenticated users are redirected to _/login_. |
593594
| _/login_ | Unauthenticated users are challenged to authenticate with GitHub. |
594-
| _/.auth/login/twitter_ | As authorization with Twitter is disabled by the route rule, `404` error is returned, which falls back to serving _/index.html_ with a `200` status code. |
595+
| _/.auth/login/twitter_ | Since authorization with Twitter is disabled by the route rule, `404` error is returned, which falls back to serving _/index.html_ with a `200` status code. |
595596
| _/logout_ | Users are logged out of any authentication provider. |
596597
| _/calendar/2021/01_ | The browser is served the _/calendar.html_ file. |
597598
| _/specials_ | The browser is permanently redirected to _/deals_. |
598599
| _/data.json_ | The file served with the `text/json` MIME type. |
599600
| _/about_, or any folder that matches client side routing patterns | The _/index.html_ file is served with a `200` status code. |
600-
| An non-existent file in the _/images/_ folder | A `404` error. |
601+
| An nonexistent file in the _/images/_ folder | A `404` error. |
601602

602603
<sup>1</sup> You can provide a custom error page by using a [response override rule](#response-overrides).
603604

@@ -617,5 +618,5 @@ See the [Quotas article](quotas.md) for general restrictions and limitations.
617618
618619
## Related articles
619620

620-
- [Set application-level settings and environment variables that can be used by backend APIs](application-settings.md)
621+
- [Set application-level settings and environment variables used by backend APIs](application-settings.md)
621622
- [Define settings that control the build process](./build-configuration.md)

0 commit comments

Comments
 (0)