This happens ONLY when I add my PWA to the home screen and run the app from there. I'm not seeing this behavior when I run the app on the mobile or desktop browser.
I'm working on a React app built using create-react-app. It works fine after running npm run build
and serving it using any local http-server. It also seems to work fine once I deploy it to Firebase or now
and open the site on Firefox or Chrome mobile browsers. However, when I hit the "Add to Homescreen" button on the pop-up, it get's added, but opening it from the homescreen icon renders the 404 route.
I used react-router's <Switch/>
component to route to a custom 404 page if no path matches the URL. Here's how I defined my Router "configuration":
<Router>
<Switch>
<Route exact path="/" component={Login} />
<Route path="/login" component={Login} />
<Route path="/sign-up" component={SignUp} />
<Route
render={() => (
<div>
<h1>Error 404: Not Found</h1>
<Link to="/">Go Home</Link>
</div>)}
/>
</Switch>
</Router>
Versions of packages in my package.json
:
react
: ^16.2.0react-scripts
: 1.1.0react-router-dom
: ^4.2.2