- Summary of the problem : a. I want to dynamically generate a page in Gatsby using a path. I have implemented the technique suggested in this question. This technique works locally i.e. on localhost but when I deploy it in production, I get the following error message :
Page Not Found Looks like you've followed a broken link or entered a URL that doesn't exist on this site.
Expected result : After the dynamic creation of the page, @reach/router should be able to able to capture the ID in the path and make it available as props in the component.
Actual result : This works locally but in production, the browser throws the above mentioned error at me. Error in console :
Failed to load resource: the server responded with a status of 404 ()
- What have I tried so far ?
In gatsby-node.js:
exports.onCreatePage = async ({ page, actions }) => {
const { createPage } = actions;
if (page.path.match(/^\/resetpassword/)) {
page.matchPath = "/resetpassword/*"
createPage(page)
}
}
In the Gatsby page resetpassword.js:
export default function ResetPassword() {
return (
<div>
<Router basepath="/">
<ResetWorker path="/resetpassword/:id" />
</Router>
</div>
)
}
function ResetWorker({ id }) {
// Here I need to access the id to make a fetch call to my node.js backend
return()
}