0

I am very new to react and trying to build an app with a react front end and MVC/web API backend. I am running into an issue.

All I've done is created a sample ASP.NET core web app with react, based on the included Visual Studio template. dotnet new react. I've made no other changes to this code.

This app is currently deployed to an Azure app service at: https://examplemvcreact.azurewebsites.net/

Expected: If I visit the url https://examplemvcreact.azurewebsites.net/weatherforecast, I would expect, the weatherforecast controller is called, and its data returned.

Actual result: I get what appears to be a blank index page, with the header rendered correctly.

However, I also notice: that if I do a full refresh, control+f5, on the url https://examplemvcreact.azurewebsites.net/weatherforecast , it DOES in fact hit the controller and give me the data.

Can anyone help me understand how this routing is working? Locally, I don't have this issue.

thank you!

  • You are most likely experiencing cache issues. Please see my post here to avoid it: https://stackoverflow.com/a/64062989/14072498 – Roar S. Dec 18 '20 at 07:28
  • @RoarS. the caching wasn't my issue per se, but you definitely lead me down the right road of finding the solution. It was the pesky service worker! I disabled that for now in my index.js, and I can now load the pages as expected, thank you for the tips! – Brent Krueger Dec 19 '20 at 22:13

1 Answers1

0

It was the service worker. I removed the import and call in my index.js file, and my mvc calls are now going back to the server as expected.