0

I am using create-react-app + react router to render a website on a subfolder (eg.: example.com/subfolder). Everything goes ok under development environment, but when I create a build to production, it does not understand the routes besides the initial Homecomponent at "example.com/subfolder".

My code is this:

<Router basename="/subfolder/">
   <main>
      <Switch>
         <Route exact path="/" component={Home}/>
         <Route path="/route-one" component={ComponentOne}/>
         <Route path="/route-two" component={ComponentTwo}/>
         <Route component={error404} />
       </Switch>
    </main>
</Router>

When I try to access ComponentOne or ComponentTwo routes, it should go to example.com/subfolder/route-one but it is not.

In my package.json, the homepage property is set to "."

Thanks for any help.

danvitoriano
  • 1,181
  • 10
  • 12

0 Answers0