Gatsby: On Production 404 is shown for 1 second before matching client paths

Created on 5 Jan 2018  Â·  4Comments  Â·  Source: gatsbyjs/gatsby

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.

question or discussion

Most helpful comment

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?

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

signalwerk picture signalwerk  Â·  3Comments

ghost picture ghost  Â·  3Comments

Oppenheimer1 picture Oppenheimer1  Â·  3Comments

kalinchernev picture kalinchernev  Â·  3Comments

mikestopcontinues picture mikestopcontinues  Â·  3Comments