Preview not working with route resolver

I have an issue where preview works fine on routes that's in the link-resolver, but routes that goes through the Route resolver does not work and I get redirected to the 404-page.

Is there anything I can do to fix this, or is it a Beta issue?

link-resolver.js

export default function(doc) {
  if (doc.isBroken) {
    return `/${doc.lang}/404`;
  }
  if (doc.type === 'homepage' && doc.lang === 'sv') {
    return '/';
  }
  if (doc.type === 'homepage' && doc.lang !== 'sv') {
    return `/${doc.lang}`;
  }
  if (doc.type === 'page') {
    return `/${doc.lang}/${doc.uid}`;
  }

  return `/${doc.lang}/404`;
}

nuxt.config.js

prismic: {
    endpoint: process.env.PRISMIC_URL,
    apiOptions: {
      accessToken: process.env.PRISMIC_API_KEY,
      routes: [
        {
          type: 'post',
          path: '/:lang/:category/:uid',
          resolvers: {
            category: 'category'
          }
        }
      ]
    },
    disableGenerator: true
  }

Hello @juliandreas, thanks for reaching out.

Your setup is correct. Is the page working in dev mode?
Maybe there's something missing in the file structure, could you share this with us?

The page is working in both dev and production, it's the preview mode that is not working.
Do you mean if the preview is working in development? Because I have no idea how to check that.

File structure
structure

@juliandreas Thanks for sending over the details of your project. To fix this you need to return null or undefined (or not return at all) from their link resolver if you want the link resolving process to fall back to the route resolver.

export default function(doc) {
  if (doc.isBroken) {
    return `/${doc.lang}/404`;
  }
  if (doc.type === 'homepage' && doc.lang === 'sv') {
    return '/';
  }
  if (doc.type === 'homepage' && doc.lang !== 'sv') {
    return `/${doc.lang}`;
  }
  if (doc.type === 'page') {
    return `/${doc.lang}/${doc.uid}`;
  }

-  return `/${doc.lang}/404`;
+  return null;
}

This thread is being monitored as an open ticket in the internal Prismic issue tracker. The Prismic support team will update this post as we get more information from our dev team. If you have a similar use-case, you can ‘Flag’ this topic to reopen and add it here.