404 when reloading a URL with nextjs + server side rendering

I have a question about generating URL's for prismic pages thats been stumping me for a while and my google-fu is failing me.

I'm new-ish to nextsjs/react. I created a dummy nextjs server side rendered blog from this prismic content repo: https://dd-sample-next-js-blog.prismic.io/documents/working/
Hosted with vercel here: https://dd-nextjs-blog-ssr.nikibrown.vercel.app/ and github code is here: GitHub - nikibrown/dd-nextjs-blog-ssr: POC nextjs / prismic blog with server-side rendering

I have a few different types of content: Homepage, blog posts and gated posts displayed on the homepage. I can click into any of these types of content and I see the URL I want. However if I refresh a single post, or try to go directly to a single post I get a 404.

Example: Go to the homepage (https://dd-nextjs-blog-ssr.nikibrown.vercel.app/) and click on the first featured post: Screenshot:

You can navigate to this just fine, but if you reload or try to go directly to the post it 404's.

https://dd-nextjs-blog-ssr.nikibrown.vercel.app/blog/another-day-another-post However if I go to the URL that is being generated by the hrefResolver https://dd-nextjs-blog-ssr.nikibrown.vercel.app/post?uid=another-day-another-post This works and I am able to directly navigate to this.

I'm thinking this has something to do with my linkResolver and hrefResolver helper functions in my prismic-configuration.js file. dd-nextjs-blog-ssr/prismic-configuration.js at main · nikibrown/dd-nextjs-blog-ssr · GitHub

I want to know how to get my URL's generated by the linkResolver to work on refresh and for direct navigation.

Thanks!

  • N

Hi Niki,

I'm investigating this issue and I will get back to you as soon as possible.

Best,
Fares

@Fares Any update on this? This is a pretty big blocker for me.

H @niki.brown

I apologize for the delay, I have checked your code and it seems what is missing the blog folder that for next.js routing such as how it is done in our blog example.

Please let me know if that solves the problem for you.
Fares

1 Like

This issue has been closed due to inactivity. Flag to reopen.