Blazor and Azure HttpTrigger

AussieBoy

Well-known member
Joined
Sep 7, 2020
Messages
78
Programming Experience
Beginner
Hi, I have been going through the tutorial on
How to create serverless websites with Blazor and Azure Functions Part One and

I can not get the blazor app to work the second half of the second part of the tutorial.
I can test with postman successfully. In the web browser I only get an error when attempting to "Add Food Type Item".

Has anyone else ran through this tutorial?

I think my problem is with cors setup.

Thanks.
 
In the web browser I only get an error when attempting to "Add Food Type Item".
Please be specific. What EXACTLY did you do and what EXACTLY happened.
 
Hi, as said I think it is to do with cors setup. Apparently there is somewhere in the code that the cors can be disabled. Don't quote me on this as this from my research and I am only beginning with this.
1657670894718.png
 
Did you set CORS to * as indicated in the link of your first post?
 
A lot of articles are pointing to a startup class. However, this project does not have a startup class.


C#:
services.AddCors(options =>
{
  options.AddPolicy("CorsPolicy",
    builder =>
    {
      builder
        .AllowAnyHeader()
        .AllowAnyMethod()
        .AllowCredentials()
        .WithOrigins("http://localhost:5000");
    });
});

But I could be shooting in the dark here.
 
Hi, Author of the tutorial here, I joined because someone sent me this link.
As long as you go to the API section of your function app, select CORS, and add in * for your allowed origins (or the domain it's served from), it should work.
Do you have your code in a repository where I could take a look at it? Something may have changed with Blazor since the article was written, but it hasn't been that long and I'm unaware of anything major. But I would like to help you out with this.
 
Back
Top Bottom