I'm facing issues when i try to create custom pages in Gatsby. I have deleted every files in pages folder other than app.js file. Now, i check for page path '/app' in onCreatePage function in gatsby-node.js. If it's found, i change the path from '/app' to '/' and create that page. After that i'll use the app.js file to route to different pages.
When everything's done and i check the routes in the browser, it's giving me an error saying 'Cannot read property page of undefined' for the route '/our-work'. I get the error only when i go to the route '/our-work'.And the default 'NotFound' page is not working. The main page gets displayed on every routes other than '/our-work' route no matter what.
Please go through the images below. Thanks!
app.js:
gatsby-node.js:
The main route - '/':
The problematic route - '/our-work':
The main page gets displayed on route where the NotFound component is expected to function: