Skip to content

Node Preview iframe outputs "Server Error: The path attribute is missing for entity with slug /blog/node-title" #216

@laurencefass

Description

@laurencefass

I raised issue with missing documentation and modified code accordingly.

import { Experiment_DrupalClient as DrupalClient } from "next-drupal"

export const drupal = new DrupalClient(
  process.env.NEXT_PUBLIC_DRUPAL_BASE_URL,
  {
    previewSecret: process.env.DRUPAL_PREVIEW_SECRET,
    auth: () =>
      "Basic " +
      Buffer.from(
        `${process.env.BASIC_AUTH_USERNAME}:${process.env.BASIC_AUTH_PASSWORD}`
      ).toString("base64"),
  }
)

For a node with a title of "node-title" this results in an error on the node preview iframe:

Server Error
Error: The path attribute is missing for entity with slug /blog/node-title

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
(api)/pages/api/preview.tsx (9:9) @ async handler

   7 |   response: NextApiResponse
   8 | ) {
>  9 |   return await drupal.preview(request, response)
     |         ^
  10 | }
  11 | 

where preview.ts is unchanged from the default installed code:

import { NextApiRequest, NextApiResponse } from "next"

import { drupal } from "lib/drupal"

export default async function handler(
  request: NextApiRequest,
  response: NextApiResponse
) {
  return await drupal.preview(request, response)
}

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions