payload icon indicating copy to clipboard operation
payload copied to clipboard

autoLogin without prefillOnly breaks Preview

Open danielkoller opened this issue 1 year ago • 0 comments

Link to reproduction

No response

Payload Version

3.0.0-beta.87

Node Version

22.5.1

Next.js Version

15.0.0-canary.104

Describe the Bug

I've encountered an issue when using the autoLogin feature (without prefillOnly) in the Payload config. When autoLogin is enabled, the live preview in the Payload admin panel no longer works.

The preview just displays a message saying "You are not allowed to preview this page" and the live preview window remains blank, even though I'm logged into the admin panel.

This may be intended behavior, but it's something that caught me off guard while I was showcasing Payload to my colleagues. Adding a note about this limitation in the Payload documentation would be really helpful, so users are aware of this potential gotcha when using autoLogin.

Huge fan of Payload, btw.

Reproduction Steps

  1. Enable the autoLogin option in the Payload config:
  admin: {
    user: 'users',
    autoLogin:
      process.env.PAYLOAD_PUBLIC_ENABLE_AUTOLOGIN === 'true'
        ? {
            email: '[email protected]',
            password: 'test',
          }
        : false,
  },
  collections: [
    /** */
  ],
})
  1. Log in to the Payload admin panel. You should be automatically logged in due to the autoLogin setting.

  2. Try to use the live preview functionality in the Payload admin panel.

Expected Behavior

The live preview should work as expected, allowing me to see the content as it would appear on the frontend.

Actual Behavior

When the autoLogin option is enabled, the live preview stops working. The preview window displays the message "You are not allowed to preview this page" and remains blank, even though I'm logged into the admin panel.

Adapters and Plugins

No response

danielkoller avatar Aug 21 '24 09:08 danielkoller