Dynamic route not found while reading static JSON

Hello there guys,

First time poster here! I have tried searching for this issue but I can’t seem to find anything related to it.

I am building a NuxtJS app but when I deploy it and try and hit the single URL for a single ‘work’ entry I get a 404 not found error. If I click this link straight from the home page the page loads fine. I get the feeling this could be due to reading the content on the page from a JSON file. Is there anything I could do to resolve this issue?

The link in question: https://pensive-meninsky-2c24f7.netlify.com/work/attic-self-storage

If you click the Attic Self Storage post on this page it loads fine: https://pensive-meninsky-2c24f7.netlify.com/work

Any help is very much appreciated! :smiley:

Hi, @WilliamDowling89, and welcome to our Netlify community site.

I think you might need to use a single page app (SPA) redirect rule as found in the documentation here:

Would you be willing to please test adding this redirect and let us know if it solves the issue?

Hi @luke,

I notice in the docs it says - " Save a plain text file called _redirects to the publish directory of your site. You can find _redirects file syntax details below."

I have dist in the my gitignore file because it is being generated by netlify can you think of another way to do this?

Thanks
William

@WilliamDowling89, the recommended workaround is to keep _redirects elsewhere in the repo and then copy it to the publish directory in the build command at Netlify.

So, if your build command is:

nuxt generate

The build command might become:

nuxt generate && cp _redirects dist

The && in the line above is a boolean logical “AND” in bash. It means the copy command won’t run if the nuxt generate command exits with an error.

If this doesn’t work, would you please send me a link to the deploy? If so, I’ll be happy to find a solution that does.