Closed dotnetnoobie closed 2 years ago
@dotnetnoobie Even following your method, I still can not hit function API.
In my environment, baseAddress
STILL is "http://localhost:5000" not "http://localhost:7071".
I seems that builder.Configuration["BaseAddress"]
do not read data from appsettings.Development.json
of Client project.
This should be addressed with #27. Thanks.
When I created a repo from the template and then cloned it to my local machine I was not able to hit the API endpoint in the functions app.
I need to update the appsettings.Development.json file with
{ "BaseAddress": "http://localhost:7071/" }
Then I also needed to update the Program.cs file with
var baseAddress = builder.Configuration["BaseAddress"] ?? builder.HostEnvironment.BaseAddress; builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(baseAddress) });
replacingbuilder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) })
Basically copying from the previous / older template
Then I was able to get the data from the function app when I navigated to the fetchdata page
I also needed to add the Shared project as it was not included in the solution when I opened it in VS (it was in the cloned repo, just not referenced in the solution when I opened it)