3 months ago
Is there a way to detect in code if a project is building?
I use payload CMS which needs to access the database during build time. This currently prevents me from using the private network to access my database.
I would want to do something like this, but I am not sure if that information is available, or if there is another way to do this?
db: mongooseAdapter({
url: isBuild
? process.env.BUILD_DATABASE_URI || '' // Use public URI here
: process.env.DATABASE_URI || '', // Use private URI here
}),
1 Replies
3 months ago
Maybe the simplest solution might work for you?
How about adding an additional enviornment variable to your npm-build-task?
"build": "cross-env BUILD=true NODE_OPTIONS=--no-deprecation next build"
And then check this via process.env:
db: mongooseAdapter({
url: process.env.BUILD
? process.env.BUILD_DATABASE_URI || '' // Use public URI here
: process.env.DATABASE_URI || '', // Use private URI here
})
3 months ago
thank you very much Maik!!
3 months ago
!s
Status changed to Solved brody • 3 months ago