payload icon indicating copy to clipboard operation
payload copied to clipboard

Inconsistent Environment Variable Naming in Payload CMS Setup for Vercel Postgres (DATABASE_URI vs. POSTGRES_URL)

Open Montekkundan opened this issue 2 months ago • 0 comments

Describe the Bug

When creating a new project using pnpx create-payload-app@latest and select Vercel Postgres as database, the payload.config.ts file includes the following configuration:

db: vercelPostgresAdapter({
  pool: {
    connectionString: process.env.POSTGRES_URL || '',
  },
}),

However, the setup instructions provide DATABASE_URI as the environment variable for the database connection. This causes the following error during schema pulling:

[⣷] Pulling schema from database...
 ⨯ [Error: [object Object]] { digest: '24910920' }

The issue is resolved when changing the .env variable from DATABASE_URI to POSTGRES_URL, or by updating the payload.config.ts file to use process.env.DATABASE_URI.

Suggested Fix: Update the default payload.config.ts to use:

connectionString: process.env.DATABASE_URI || '',

Or update the setup documentation to mention POSTGRES_URL as the expected environment variable.

Link to the code that reproduces this issue

https://github.com/Montekkundan/payload-vercel

Reproduction Steps

pnpx create-payload-app@latest

select Vercel Postgres as database

start with pnpm dev. http://localhost:3000/ will not work until you change env variable in payload.config.ts

Which area(s) are affected? (Select all that apply)

db-vercel-postgres

Environment Info

> [email protected] payload /Users/montekkundan/Developer/coding/payload-vercel
> cross-env NODE_OPTIONS=--no-deprecation payload "info"


Binaries:
  Node: 20.18.1
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.15.0
Relevant Packages:
  payload: 3.7.0
  next: 15.1.0
  @payloadcms/email-nodemailer: 3.7.0
  @payloadcms/graphql: 3.7.0
  @payloadcms/live-preview: 3.7.0
  @payloadcms/live-preview-react: 3.7.0
  @payloadcms/next/utilities: 3.7.0
  @payloadcms/payload-cloud: 3.7.0
  @payloadcms/plugin-form-builder: 3.7.0
  @payloadcms/plugin-nested-docs: 3.7.0
  @payloadcms/plugin-redirects: 3.7.0
  @payloadcms/plugin-search: 3.7.0
  @payloadcms/plugin-seo: 3.7.0
  @payloadcms/richtext-lexical: 3.7.0
  @payloadcms/translations: 3.7.0
  @payloadcms/ui/shared: 3.7.0
  react: 19.0.0
  react-dom: 19.0.0
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.2.0: Fri Dec  6 19:03:40 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6041
  Available memory (MB): 65536
  Available CPU cores: 16

Montekkundan avatar Dec 16 '24 17:12 Montekkundan