Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

Adding Capacitor Localhost To Azure App Service Cors

- 07 Aug 2020

Again… just a quick post.  The UI will not validate and allow you to add capacitor://localhost to the CORS settings in Azure App Services.  Here are two ways to work around it.

Use the CLI

Use the CLI/Powershell if you need to do this without a UI.  Here is how to do it using az:

az webapp cors add –allowed-origins capacitor://localhost –name yourWebApp –resource-group webappResourceGroup –subscription yourSubscription

Use Azure Resource Explorer

Use the Web UI for simplicity

Go to: https://resources.azure.com/ and login.

Search for the Web App by name, find the (Microsoft.Web/Sites) link and click on it:

image

Ensure you select the Read/Write button on the top right and then the Edit button on the top left:

image

find the cors object and add the capacitor://localhost entry.  Ensure there is a comma after the existing entries if any and scroll back to the top and push the Patch button:

image

How to test

You can use curl, Fiddler, Postman… just build the request and ensure it returns 200 and 1 in the body

Here is an example from Postman:

image

<< Go Back