Skip to content

Commit 22c4dee

Browse files
authored
feat: warn if deploying to vercel and any upload collection missing storage adapter (#10391)
A large number of users have been confused why their upload collection doesn't work as expected when deploying to Vercel. This is because by default, Payload uses local disk storage for file uploads - which will not function properly in that environment. This adds a warning if a user is deploying on Vercel, and they have any upload collection missing an adapter - aka, writing to disk.
1 parent c1abd16 commit 22c4dee

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/payload/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,20 @@ export class BasePayload {
653653
)
654654
}
655655

656+
// Warn if user is deploying to Vercel, and any upload collection is missing a storage adapter
657+
if (process.env.VERCEL) {
658+
const uploadCollWithoutAdapter = this.config.collections.filter(
659+
(c) => c.upload && c.upload.adapter === undefined, // Uploads enabled, but no storage adapter provided
660+
)
661+
662+
if (uploadCollWithoutAdapter) {
663+
const slugs = uploadCollWithoutAdapter.map((c) => c.slug).join(', ')
664+
this.logger.warn(
665+
`Collections with uploads enabled require a storage adapter when deploying to Vercel. Collections without storage adapters: ${slugs}. See https://payloadcms.com/docs/upload/storage-adapters for more info.`,
666+
)
667+
}
668+
}
669+
656670
this.sendEmail = this.email['sendEmail']
657671

658672
serverInitTelemetry(this)

0 commit comments

Comments
 (0)