Dynamic Routes work but show 404 in consoleMarch 12, 2019 at 9:42pm (Edited 1 month ago)
I like the idea of having a subset of dynamic routes for pages that don't need to be statically built, in my case, a careers/job listings board.
Almost all other pages on the site are defined in static.config, including the careers page.
From what I can tell from the dynamic routes with reach router guide, the app level component should wrap all dynamic routes and React-Static's Routes component in a Router component. Here's a snippet from my app level component.
...<div className='content'><Router><JobPageTemplate path='careers/:id' /><Routes default /></Router></div>...
Then I use Reach Router's Link component on the static rendered careers page.
The dynamic routes work as expected in dev and prod, but when I open the console, I get a 404 error for each link to a dynamic route visible in the viewport. As a scroll down my list of job links, a new 404 error pops up when it becomes visible.
I'm not sure if I'm doing something wrong or if it's a bug. @tannerlinsley have you seen this before? Is there something I can do to avoid the "false" 404 errors?
March 14, 2019 at 8:39pm
We might be able to expose a way for you to whitelist a dynamic route or group of routes to not make the routeInfo requests.
The 404 errors as of right now are not harmful, they are simply a means by which RS checks to see if a path is in fact a static path
March 15, 2019 at 2:55am
Yeah, it seems like a user might not notice, but having that many console errors on a production site doesn't sit well with me. I actually avoided this by using query parameters and a static shell page.
It would be great to have a way to whitelist or explicitly designate dynamic routes in RS and avoid the false 404s.
Loving React Static BTW. How can I get my site on the list of sites made with RS?
March 19, 2019 at 11:19am
@bram-l, we also have a prefetch runner that works on any <a href> link that becomes visible on the page. With that said, I think a whitelist is the way to go. You would return it in your config, same as routes. It would probably need to support globs too. Or at the very least, regex.
April 2, 2019 at 5:08pm