Search code examples
c#reactjs.netasp.net-mvcprogressive-web-apps

Dotnet React Template - is it possible to use /index.html


If I use pure Create React Application (without dotnet), then I can open the react application in two ways (after yarn start):

  • https://localhost:3000/
  • https://localhost:3000/index.html

enter image description here enter image description here

But if I use Dotnet React Template, then there is only one way I can open the application (when I add index.html, I only see the dotnet part of the app, but not react) after dotnet run:

  • https://localhost:5001/
  • https://localhost:5001/index.html

enter image description here enter image description here

I would like to find a way to use index.html here as well.

Why am I asking. I recently tried adding my site as a Bookmark to iPhone's Home Screen.

It turned out that this doesn't just work as a link, but iOS now interprets those sites as Progressive Web Application. That is, additional requirements are imposed on the site. And one of them is having a working index.html.

This is why I would like my Dotnet React application to work properly with /index.html


Solution

  • Go get ClientApp/src/App.js and change the first route to below.

    <Route exact path={['/', '/index.html']} component={Home} />