Secret retrieval during runtime in payload v2 #4158
Unanswered
jkauppinen
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @jkauppinen, I think this PR might help you with part of problem: #4028. You have some flexibility on how you start Payload. // server.ts
const start = async () => {
app.use('/assets', express.static(path.resolve(__dirname, './assets')))
// Initialize Payload
await payload.init({
config,
express: app,
onInit: async () => {
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
},
secret: process.env.PAYLOAD_SECRET,
})
// Add your own express routes here
app.listen(3000)
} // payload.config.ts
export const config: Config = async () => {
const secrets = await getSecrets();
return {
db: mongooseAdapter({
url: secrets['DB_URL'],
}),
editor: lexicalEditor(),
}
// the rest of the config....
} I haven't tried it, but I think this should give you what you need. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In payload v1 we retrieved secrets from Azure Key Vault before starting payload in server.ts
This worked very nicely. In payload v2 the configuration of database is moved to payload.config.ts:
This complicates the setup and breaks our existing model, as we don't want to store secrets in environment variables in production.
Couple of questions:
Beta Was this translation helpful? Give feedback.
All reactions