React Router V4 but on a different homepage in package.json... fix 404 not found?

Viewed 3531

package.json

"name": "debate",
"homepage": "/debate", // I THINK THIS IS THE PROBLEM
"version": "0.1.0",
"private": true,
"dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-router-dom": "^4.1.1"
}

App.js

<BrowserRouter>
    <div>
        <Route path='/thread/:pathParam?' component={Thread}/>
        <Route path='/post' component={Post}/>
    </div>
</BrowserRouter>

When I test the app on... [ http://localhost:3000/thread ] everything works perfectly well.

When I build the app for production and upload my files to my server, the directory [ http://www.example.com/debate/thread ] gives a 404 error saying "The requested URL /debate/thread/ was not found on this server."

The requested URL /debate/thread/ was not found on this server.

[ http://www.example.com/debate/ ] still works perfectly well.

I'm not sure how to get react-router-dom to recognize that we're actually on a sub-directory...

1 Answers
Related