Support Forums

Page Not Found after deploy using Public/Private router

My website dev environment:

Build log:

10:20:47 AM: (Netlify Build completed in 59.1s)
10:20:47 AM: Starting post processing
10:20:47 AM: Post processing - HTML
10:20:47 AM: Post processing - header rules
10:20:47 AM: Post processing - redirect rules
10:20:47 AM: Post processing done
10:20:47 AM: Caching artifacts
10:20:47 AM: Site is live ✨
10:20:48 AM: Build script success
10:21:15 AM: Finished processing build request in 1m49.098458264s

Hi there! I’m using React and react-router-dom in my website. I have two routers: one public and another one private, it depends on userContext.

const Router = (): JSX.Element => {
    const { user } = useContext(UserContext);

    if (!user) {
        return (
                    <img src="./front-login.png" alt="Front" />
                        Tome <b>decisões</b> <br /> Mais <b>assertivas</b>{' '}
                            <Route path="/" component={Login} exact />

    return (
                <NavigationMenu />
                    <Header />
                        <Route path="/" component={Dashboard} exact />
                        <Route path="/pesquisas" component={Surveys} />
                        <Route path="/segmentacao" component={Segmentation} />
                        <Route path="/recompensas" component={Gifts} />
                        <Route path="/respondentes" component={Respondents} />
                        <Route path="/ajuda" component={Help} />
                        <Route path="/configuracoes" component={Settings} />

export default Router;

in the public router, the problem is that the route “/recadastro” is returning 404 not found! But i’m facing this problem only after deploy. Locally, i’m not facing this problem in local host.

Any tips?

Hey there, @jgsn.adv :wave:

Thanks so much for reaching out about this.

The first place to look for Page Not Found errors is this Support Guide. Be sure to read the first few comments, as they offer additional steps to take as well:

Up next, I encourage you to work through this thread that also discusses Page Not Found errors with react-router-dom. This seems very relevant to what you are encountering!

Let us know if these help.

1 Like

thank you so much! it worked:

Thanks very much Mr. @jaylowe1 and @luke, it works, just to recap:

  1. Add _redirects file in your public folder
  2. Write down inside file:

/* /index.html 200

In my case I have no issues with my builder adding .txt extension, I’m using CRA(Create React App).

You guys Rock!

1 Like

Great to hear, @jgsn.adv! I am so glad everything is working for you! :netliconfetti:

1 Like