Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
ReactJS: Getting 404 when a /about page is opened

This is the first time I'm deploying a React Web App to the firebase hosting. In my index.html file I only have the root div:

<body>
    <div id="root" class="container"></div>
</body>

That's all there is in the body. Then I have an index.js in the src folder in which I have:

import { BrowserRouter as Router, Route } from "react-router-dom";'
import HomeScreen from "./screens/HomeScreen";
import AboutScreen from "./screens/AboutScreen";
...
ReactDOM.render(
    <Router>
        <div>
            <Route exact path="/" component={HomeScreen} />
            <Route exact path="/about" component={AboutScreen} />
        </div>
    </Router>,
    document.getElementById("root"))

Then to open the about page I have linked it as:

import { Container, Nav, Navbar } from 'react-bootstrap';
...
<Nav.Link href="/about">About</Nav.Link>

When I do npm run build and then firebase deploy it deploys and I can see the changes on the home page. But when I click on about it gives me 404

404 error picture

I have the folder named build which is the public folder and after the build, it only has index.html and 404.html and a static/js folder that has some generated js and txt.

So, I'm not sure why I'm getting 404. In dev build i.e. localhost the navigation works fine.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

For single page applications, redirect rules must be specified. Every routes should be redirected from index.html file

You need to specify the deployment directory being deployed and the redirect rules

This is my react app being deployed to firebase hosting alongside firebase functions

{
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

That is because it is a static deployment of a single index.html, about.html does not exist, you can only access to the index.html, and the other views "doesn't" because is a single-page-application, but you can redirect all URL other than "/" to the index.html file, editing the firebase.json

"rewrites": [ {
  "source": "**",
  "destination": "/index.html"
} ]
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!