Prismic Preview not setting params on redirect in Next JS (works on local but not live)

In our project we build out the URL for a page dynamically based on values contained in the page. In using this, our preview endpoint makes a fetch for page data when making the redirect which looks like this:

export default async (req, res) => {
  const client = createClient({ req, fetch })
  const documentId = req.query.documentId;
  const {clientName, campaignName} = await getClientAndCampaignName(client, documentId);
  await setPreviewData({ req, res })
  await redirectToPreviewURL({
    linkResolver: doc => linkResolver(doc, clientName, campaignName)

Finding the client and campaign name, two relationship values, to build out the url. Link resolver that is used:

export function linkResolver(doc, clientName, campaignName) {
  const { isCampaignNameInURL, isClientNameInURL } = || {};
  const campaignRoute = isCampaignNameInURL && campaignName ? `/${campaignName}` : ''
  const clientRoute = isClientNameInURL && clientName ? `/${clientName}` : ''
  if (doc.uid) {
    return clientRoute + campaignRoute + `/${doc.uid}`
  return null;

This works correctly on our local servers, building out the dynamic url for a preview, however once we deploy the live version of this we run into an "Internal Server Error" when attempting to preview a page. Leaving us on the /api/preview route with no token or documentId params.

Hello @justin.mccarthy_test, have you followed the Preview documentation for Next?

I recommend you go step by step to see if there's a missing setup in your configuration.