CORS Wild Card support in Azure
The apicors azure portal end point does not accept https://*.domain.com/ as a valid 'allowed origin'
A little red exclamation appears and says it must be in the format [HTTP:HTTPS]://[www.]domain.[TLD][:portnumber]
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 59bca5db-1196-2a8b-a0d8-4e89b2382288
- Version Independent ID: d3f332c4-4c60-039e-0e1e-bc6b11831f87
- Content: Enable Cross-Origin Requests (CORS) in ASP.NET Core
- Content Source: aspnetcore/security/cors.md
- Product: asp.net-core
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
@guardrex should that info go in an Azure doc? @OzBob where do you think it should go?
@OzBob so ...
https://domain.com/
or just ...
https://domain.com
doesn't work?
Correction: https://stackoverflow.com/a/49943569/1586498 and https://github.com/aspnet/CORS/pull/76 say that it is now supported in code.
I still can't get it to be a valid origin in the azure portal webapp api CORS form.

@Rick-Anderson is there docs on how to use that CORS feature of the Azure Portal?
@SyntaxC4 @kichalla @pranavkm would that go in an Azure doc?
@CamSoper
is there docs on how to use that CORS feature of the Azure Portal?
Support for wildcard subdomains is a feature of the ASP.NET Core CORS middleware, not actually part of the CORS (fetch) spec. My guess is the Azure service (is this Azure App Services) does not support this feature.
Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.
I still don't understand how you want us to get around this issue. Azure Static App creates a dynamic url for each environment so how can it call an azure function if the URL changes? Is it just unusable?
URL example: https://smoked-bacon-[032fe1c0f-2.eastus2].azurestaticapps.net (the middle section changes for each deployment)
Any news on it? vercel by example create random subdomains!
@weisssean @OzBob @clintnetwork if you can recommend the appropriate azure document, I'll transfer this issue to Azure and try to get some help.
Documents that mention CORS that would benefit from noting the limitations of the UI in the portal and maybe (i haven't tested it yet) how to use the Azure CLI instead:
https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-rest-api#add-cors-functionality https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-5.0
Azure CLI CORS commands: https://docs.microsoft.com/en-us/cli/azure/webapp/cors?view=azure-cli-latest#az_webapp_cors_add
@OzBob can you open issues there? This doesn't seem to be related to ASP.NET Core
Found the solution for this issue -- APIM CORS with Wild Card
-
Remove CORS policy from APIM for all operations of service.
-
Add an OPTIONS operation for those APIs that needs CORS with wildcards. E.g.,
2.1. With perspective to the operation GET /service/items/{id}
2.2. Add in APIM a new corresponding operation OPTIONS /service/items/{id}
- Configure the service with the customized CORS policy, like

app.UseCors(this.allowSpecificOrigins);
I still don't understand how you want us to get around this issue. Azure Static App creates a dynamic url for each environment so how can it call an azure function if the URL changes? Is it just unusable?
URL example: https://smoked-bacon-[032fe1c0f-2.eastus2].azurestaticapps.net (the middle section changes for each deployment)
First of all, even with your example case, just what would be your proposal for a wildcard'ed solution? *.azurestaticapps.net? So, like, the entire static apps world? Right, so, you actually have two problems, how to wildcard CORS and how to better control the subdomain names of your static apps so that they are more predictably patterned.
This: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-rest-api#how-do-i-set-allowed-origins-to-a-wildcard-subdomain
... claims that wildcard origin allowances are applicable via the CLI, even if the Azure portal UX doesn't yet allow it.
And then, controlling your static app URLs, you probably need an actual wildcard certificate of your own (as would anyone else looking to configure multiple subdomains. And then, this; https://learn.microsoft.com/en-us/azure/static-web-apps/custom-domain
Actually @cbrunettigg, what I was suggesting was to wildcard the part that changes when a static web app gets deployed, so:
https://smoked-bacon-[*].azurestaticapps.net/.