I configured the gatsby-plugin-create-client-paths plugin like this:
{
resolve: gatsby-plugin-create-client-paths,
options: { prefixes: [/apply/*] },
},
On development everything works fine but after building the site, when I browse a url like /apply/test
Gatsby shows the 404 page for a split second before navigation to the /pages/apply/index.js page correctly.
You need to add rewrites to your server or service so /apply/:param will point to /apply so you would get desired page without getting 404.
Where are you hosting your website?
Thanks @pieh. We are using Netlify so I added a _redirects file. I tried to configure it twice and both times I still get the same result as before. By the way, I get the same 404 showing up also when running "gatsby build" + "gatsby serve".
Do you happen to have any link to a working example so I can compare what I'm doing?
Netlify _redirects file attempt 1:
/apply/* /apply
Netlify _redirects file attempt 2:
/apply/* /apply/:splat
(I also checked Netlify build log and there were no errors regarding the _redirects file processing)
this does work for me
/search/:query /search 200
remember to place _redirects in your project static directory so it end up in public after the build
@pieh thanks for supplying the solution — closing this.
Most helpful comment
You need to add rewrites to your server or service so
/apply/:paramwill point to/applyso you would get desired page without getting 404.Where are you hosting your website?