Thanks, Jason.
I did find that the problem must lie in the Azure DevOps build/release process. If I publish the code directly from Visual Studio I do not have any CORS issues.
I haven't looked into what the difference is from publishing in VS versus using the DevOps pipelines.
If you have any ideas, let me know!
CORS error with new app service
I have a Blazor webassembly that runs as an app service. It calls a .net core api also running as an app service in the same resource group. I set this up a while ago and it has been running with no issues. Now I wanted to add a second api. I created a new app service again in the same resource group, but I am getting CORS errors when I try to call the new api. I have the AddCors set in the api code. If I comment that out in the code and use the portal CORS settings, I then get a 500 internal server error.
I created another new app service and deployed the old api to it and it also gets the same issues. But it works fine when deployed to the old app service that was created a while ago.
What changed when creating a new app service? I noticed the app insights gets created by default now and that was not the case before. I tried creating a new app service without app insights turned on, but still the issues are there when calling any api code deployed to that app service.
Is there some setting on a new app service that can be changed to get this to work? What changes have been made to app services?
2 answers
Sort by: Newest
-
Craig Stone 1 Reputation point
2021-07-30T23:41:02.28+00:00 -
JasonPan - MSFT 4,281 Reputation points Microsoft Vendor
2021-07-30T06:14:16.507+00:00 Hi @Craig Stone
First of all, suppose there is a program named
ServerA
as the api interface. When other programs need to call the interface inServerA
, we usually set it in the codeAddCors
, or set it in IIS (the way it is reflected in the program) It can be in theweb.config
file of the project, in the azure webapp, it can be set in the portal).Suppose there is a webapp named
ClientA
that needs to callServerA's interface
, then inServerA's
portal, the easiest way is to addClientA's domain
name in the figure below. Assuming that any other programs are also adding other domain names inServerA
.Please follow the methods below to troubleshoot the error you are currently experiencing:
- First of all, in the webapp you will be called, you don’t need to use the
AddCors
method in the code to control cross-domain issues. Fill in*
in theCORS
of the portal. Then perform your previous test, (please make sure you are called In the program, the above operation was carried out). *Explain the reason: Filling in * is to ensure that you have not made other wrong configurations, which may cause problems.* - If according to step 1, the program can be called normally without cross-domain error, then please fill in the called webapp (assuming it is server), and it will visit his webapps
(Client side) URL. - If the problem persists, it is recommended to create a new resource group, create a new webapp, redeploy and test.
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.Best Regards,
Jason - First of all, in the webapp you will be called, you don’t need to use the