payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
23.53k stars 1.5k forks source link

Error when I use payload in next.js middleware #8285

Closed zelenovsky closed 1 week ago

zelenovsky commented 1 week ago

Link to reproduction

No response

Environment Info

Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: N/A
  pnpm: 9.5.0
Relevant Packages:
  payload: 3.0.0-beta.107
  next: 15.0.0-canary.104
  @payloadcms/db-postgres: 3.0.0-beta.107
  @payloadcms/graphql: 3.0.0-beta.107
  @payloadcms/next/utilities: 3.0.0-beta.107
  @payloadcms/richtext-lexical: 3.0.0-beta.107
  @payloadcms/translations: 3.0.0-beta.107
  @payloadcms/ui/shared: 3.0.0-beta.107
  react: 19.0.0-rc-06d0b89e-20240801
  react-dom: 19.0.0-rc-06d0b89e-20240801
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:12 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 12

Describe the Bug

Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs.

Reproduction Steps

// middleware.ts
export function middleware(request: NextRequest) {
    const payload = await getPayload({ config: configPromise });
}

Adapters and Plugins

No response

fofoy commented 1 week ago

Hey @zelenovsky, isn't it related to this issue with Next.js ? https://github.com/vercel/next.js/discussions/46722

zelenovsky commented 1 week ago

@fofoy yes, you are right! sorry, this is so crucial for me, I need to call payload to get session on every request. Now I am confused

github-actions[bot] commented 1 week ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.