Skip to content

Commit 1931a31

Browse files
committed
updates
1 parent 9b84e40 commit 1931a31

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

articles/app-service/app-service-web-tutorial-rest-api.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,29 +154,29 @@ Next, you enable the built-in CORS support in App Service for your API.
154154
dotnet run
155155
```
156156

157-
1. Navigate to the browser app at `http://localhost:5000`. Open the developer tools window in your browser (`Ctrl`+`Shift`+`i` in Chrome for Windows) and inspect the **Console** tab. You should now see the error message, `No 'Access-Control-Allow-Origin' header is present on the requested resource`.
157+
1. Navigate to the browser app at `http://localhost:5000`. Open the developer tools window in your browser (**Ctrl**+**Shift**+**i** in Chrome for Windows) and inspect the **Console** tab. You should now see the error message, `No 'Access-Control-Allow-Origin' header is present on the requested resource`.
158158

159-
![CORS error in browser client](./media/app-service-web-tutorial-rest-api/azure-app-service-cors-error.png)
159+
![Screenshot of the CORS error in the browser client.](./media/app-service-web-tutorial-rest-api/azure-app-service-cors-error.png)
160160

161-
The domain mismatch between the browser app (`http://localhost:5000`) and remote resource (`http://<app_name>.azurewebsites.net`) is recognized by your browser as a cross-origin resource request. Also, the fact that your REST API the App Service app is not sending the `Access-Control-Allow-Origin` header, the browser has prevented cross-domain content from loading.
161+
The domain mismatch between the browser app (`http://localhost:5000`) and remote resource (`http://<app_name>.azurewebsites.net`) is recognized by your browser as a cross-origin resource request. Also, because your REST API the App Service app isn't sending the `Access-Control-Allow-Origin` header, the browser has prevented cross-domain content from loading.
162162
163-
In production, your browser app would have a public URL instead of the localhost URL, but the way to enable CORS to a localhost URL is the same as a public URL.
163+
In production, your browser app would have a public URL instead of the localhost URL, but the process for enabling CORS to a localhost URL is the same as the process for a public URL.
164164
165165
### Enable CORS
166166
167-
In the Cloud Shell, enable CORS to your client's URL by using the [`az webapp cors add`](/cli/azure/webapp/cors#az-webapp-cors-add) command. Replace the _&lt;app-name>_ placeholder.
167+
In Cloud Shell, enable CORS to your client's URL by using the [`az webapp cors add`](/cli/azure/webapp/cors#az-webapp-cors-add) command. Replace the _&lt;app-name>_ placeholder.
168168

169169
```azurecli-interactive
170170
az webapp cors add --resource-group myResourceGroup --name <app-name> --allowed-origins 'http://localhost:5000'
171171
```
172172

173-
You can add multiple allowed origins by running the command multiple times or by adding a comma-separate list in `--allowed-origins`. To allow all origins, use `--allowed-origins '*'`.
173+
You can add multiple allowed origins by running the command multiple times or by adding a comma-separated list in `--allowed-origins`. To allow all origins, use `--allowed-origins '*'`.
174174

175175
### Test CORS again
176176

177177
Refresh the browser app at `http://localhost:5000`. The error message in the **Console** window is now gone, and you can see the data from the deployed API and interact with it. Your remote API now supports CORS to your browser app running locally.
178178

179-
![CORS success in browser client](./media/app-service-web-tutorial-rest-api/azure-app-service-cors-success.png)
179+
![Screenshot that shows CORS support in the browser client.](./media/app-service-web-tutorial-rest-api/azure-app-service-cors-success.png)
180180

181181
Congratulations, you're running an API in Azure App Service with CORS support.
182182
@@ -188,34 +188,34 @@ Congratulations, you're running an API in Azure App Service with CORS support.
188188
189189
#### App Service CORS vs. your CORS
190190
191-
You can use your own CORS utilities instead of App Service CORS for more flexibility. For example, you may want to specify different allowed origins for different routes or methods. Since App Service CORS lets you specify one set of accepted origins for all API routes and methods, you would want to use your own CORS code. See how ASP.NET Core does it at [Enabling Cross-Origin Requests (CORS)](/aspnet/core/security/cors).
191+
You can use your own CORS utilities instead of App Service CORS for more flexibility. For example, you might want to specify different allowed origins for different routes or methods. Since App Service CORS lets you specify only one set of accepted origins for all API routes and methods, you would want to use your own CORS code. See how CORS is enabled in ASP.NET Core at [Enable CORS](/aspnet/core/security/cors).
192192
193-
The built-in App Service CORS feature does not have options to allow only specific HTTP methods or verbs for each origin that you specify. It will automatically allow all methods and headers for each origin defined. This behavior is similar to [ASP.NET Core CORS](/aspnet/core/security/cors) policies when you use the options `.AllowAnyHeader()` and `.AllowAnyMethod()` in the code.
193+
The built-in App Service CORS feature doesn't have options to allow only specific HTTP methods or verbs for each origin that you specify. It will automatically allow all methods and headers for each origin defined. This behavior is similar to [ASP.NET Core CORS](/aspnet/core/security/cors) policies when you use the options `.AllowAnyHeader()` and `.AllowAnyMethod()` in the code.
194194

195195
> [!NOTE]
196-
> Don't try to use App Service CORS and your own CORS code together. When used together, App Service CORS takes precedence and your own CORS code has no effect.
196+
> Don't try to use App Service CORS and your own CORS code together. If you try to use them together, App Service CORS takes precedence and your own CORS code has no effect.
197197
>
198198
>
199199
200200
#### How do I set allowed origins to a wildcard subdomain?
201201
202-
A wildcard subdomain like `*.contoso.com` is more restrictive than the wildcard origin `*`. However, the app's CORS management page in the Azure portal doesn't let you set a wildcard subdomain as an allowed origin. However, you can do it using the Azure CLI, like so:
202+
A wildcard subdomain like `*.contoso.com` is more restrictive than the wildcard origin `*`. The app's CORS management page in the Azure portal doesn't let you set a wildcard subdomain as an allowed origin. However, you can do that by using Azure CLI, like so:
203203
204204
```azurecli-interactive
205205
az webapp cors add --resource-group <group-name> --name <app-name> --allowed-origins 'https://*.contoso.com'
206206
```
207207
208208
#### How do I enable the ACCESS-CONTROL-ALLOW-CREDENTIALS header on the response?
209209
210-
If your app requires credentials such as cookies or authentication tokens to be sent, the browser may require the `ACCESS-CONTROL-ALLOW-CREDENTIALS` header on the response. To enable this in App Service, set `properties.cors.supportCredentials` to `true`.
210+
If your app requires credentials such as cookies or authentication tokens to be sent, the browser might require the `ACCESS-CONTROL-ALLOW-CREDENTIALS` header on the response. To enable this in App Service, set `properties.cors.supportCredentials` to `true`:
211211
212212
```azurecli-interactive
213213
az resource update --name web --resource-group <group-name> \
214214
--namespace Microsoft.Web --resource-type config \
215215
--parent sites/<app-name> --set properties.cors.supportCredentials=true
216216
```
217217
218-
This operation is not allowed when allowed origins include the wildcard origin `'*'`. Specifying `AllowAnyOrigin` and `AllowCredentials` is an insecure configuration and can result in cross-site request forgery. To allow credentials, try replacing the wildcard origin with [wildcard subdomains](#how-do-i-set-allowed-origins-to-a-wildcard-subdomain).
218+
This operation isn't allowed when allowed origins include the wildcard origin `'*'`. Specifying `AllowAnyOrigin` and `AllowCredentials` isn't secure. Doing so can result in cross-site request forgery. To allow credentials, try replacing the wildcard origin with [wildcard subdomains](#how-do-i-set-allowed-origins-to-a-wildcard-subdomain).
219219
220220
[!INCLUDE [cli-samples-clean-up](../../includes/cli-samples-clean-up.md)]
221221
@@ -225,11 +225,11 @@ This operation is not allowed when allowed origins include the wildcard origin `
225225
What you learned:
226226
227227
> [!div class="checklist"]
228-
> * Create App Service resources using Azure CLI
229-
> * Deploy a RESTful API to Azure using Git
230-
> * Enable App Service CORS support
228+
> * Create App Service resources using Azure CLI.
229+
> * Deploy a RESTful API to Azure using Git.
230+
> * Enable App Service CORS support.
231231
232-
Advance to the next tutorial to learn how to authenticate and authorize users.
232+
Go to the next tutorial to learn how to authenticate and authorize users.
233233
234234
> [!div class="nextstepaction"]
235235
> [Tutorial: Authenticate and authorize users end-to-end](tutorial-auth-aad.md)

0 commit comments

Comments
 (0)