You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/static-web-apps/configuration.md
+26-25Lines changed: 26 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,11 +26,11 @@ You can define configuration for Azure Static Web Apps in the _staticwebapp.conf
26
26
> [!NOTE]
27
27
> [_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.
28
28
>
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.
30
30
31
31
## File location
32
32
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.
34
34
35
35
See the [example configuration](#example-configuration-file) file for details.
36
36
@@ -94,7 +94,7 @@ This rule matches requests for the file _/profile/index.html_. Because _index.ht
94
94
95
95
#### <aname="wildcards"></a>Wildcard pattern
96
96
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.
98
98
99
99
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.
100
100
@@ -173,7 +173,7 @@ You can create new roles as needed in the `allowedRoles` array. To restrict a ro
173
173
174
174
#### Restrict access to entire application
175
175
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.
177
177
178
178
The following example configuration blocks anonymous access and redirects all unauthenticated users to the Microsoft Entra sign-in page.
179
179
@@ -199,7 +199,7 @@ The following example configuration blocks anonymous access and redirects all un
199
199
200
200
## Fallback routes
201
201
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.
203
203
204
204
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.
205
205
@@ -222,7 +222,7 @@ You can control which requests return the fallback file by defining a filter. In
222
222
}
223
223
```
224
224
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.
226
226
227
227
```files
228
228
├── images
@@ -238,13 +238,13 @@ For example, with the directory structure below, the above navigation fallback r
238
238
239
239
| Requests to... | returns... | with the status... |
240
240
|--|--|--|
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`|
248
248
249
249
> [!IMPORTANT]
250
250
> 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 (`""`).
The following example implements a custom CORS configuration.
268
268
@@ -354,14 +354,15 @@ In addition to IP address blocks, you can also specify [service tags](../virtual
354
354
355
355
## Authentication
356
356
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
+
358
359
*[Custom authentication providers](authentication-custom.md) use the `auth` section of the settings file.
359
360
360
361
For details on how to restrict routes to authenticated users, see [Securing routes with roles](#securing-routes-with-roles).
361
362
362
363
### Disable cache for authenticated paths
363
364
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.
365
366
366
367
To disable Azure Front Door caching for secured routes, add `"Cache-Control": "no-store"` to the route header definition.
367
368
@@ -379,7 +380,7 @@ For example:
379
380
380
381
## Forwarding gateway
381
382
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.
383
384
384
385
> [!NOTE]
385
386
> 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
422
423
423
424
## Trailing slash
424
425
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.
426
427
427
428
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.
428
429
@@ -447,7 +448,7 @@ When you're setting `trailingSlash` to `always`, all requests that don't include
447
448
448
449
### Never
449
450
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`.
451
452
452
453
```json
453
454
"trailingSlash": "never"
@@ -464,7 +465,7 @@ When setting `trailingSlash` to `never`, all requests ending in a trailing slash
464
465
465
466
### Auto
466
467
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.
468
469
469
470
```json
470
471
"trailingSlash": "auto"
@@ -479,7 +480,7 @@ When you set `trailingSlash` to `auto`, all requests to folders are redirected t
479
480
|_/contact/_| The _/contact.html_ file |`301`|_/contact_|
480
481
|_/contact.html_| The _/contact.html_ file |`301`|_/contact_|
481
482
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.
483
484
484
485
By default, when the `trailingSlash` configuration is omitted, Static Web Apps applies the following rules:
485
486
@@ -591,13 +592,13 @@ Based on the above configuration, review the following scenarios.
591
592
|_/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. |
592
593
|_/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_. |
593
594
|_/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. |
595
596
|_/logout_| Users are logged out of any authentication provider. |
596
597
|_/calendar/2021/01_| The browser is served the _/calendar.html_ file. |
597
598
|_/specials_| The browser is permanently redirected to _/deals_. |
598
599
|_/data.json_| The file served with the `text/json` MIME type. |
599
600
|_/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. |
601
602
602
603
<sup>1</sup> You can provide a custom error page by using a [response override rule](#response-overrides).
603
604
@@ -617,5 +618,5 @@ See the [Quotas article](quotas.md) for general restrictions and limitations.
617
618
618
619
## Related articles
619
620
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)
621
622
-[Define settings that control the build process](./build-configuration.md)
0 commit comments