Anytime!
Alright, thank you again
If you do find out, let me know for sure, im glad it works though 😄
That's the extent of my knowledge though, not sure if there's some process that pulls it in the first time
Otherwise they are pulled in via an .env file and the dotenv library
And im not sure, typically environment variables are only added if they are declared as part of a command or manually declared
Good question, not the first time I've seen it too
Hmm
It was working yesterday without dotenv/config
it works now, thank you. But may I know why it failed before?
Then try logging again
at the top
import 'dotenv/config'
can you try to add
Okay lets try to fix that
Ah
It prints but it does not contain the variables in my .env
Try logging it prior to the buildConfig
And when doing so, is it an object with the expected variables
For instance, can you log the value of your process.env
Is your .env being picked up correctly?
This was working yesterday in sveltekit, but today if fails with this error after I npm run dev:
Error: missing secret key. A secret key is needed to secure Payload.
But my config has the secret PAYLOAD_SECRET property from my .env file:
import path from 'path'
import { buildConfig } from 'payload'
import { fileURLToPath } from 'url'
import { postgresAdapter } from '@payloadcms/db-postgres'
import { Products } from './collections/Products'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
collections: [Products],
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: postgresAdapter({
pool: {
connectionString: process.env.DATABASE_URI || '',
},
})
})
I then use the local API as such, this is where the error comes from but it was working yesterday
import config from '../../payload.config'
import { getPayload } from 'payload';
const payload = await getPayload({ config });
export async function load() {
const data = await payload.findByID({
collection: 'products',
id: 1
});
return data;
}
I have not changed my package.json at all, in fact, I only ran the command since yesterday and now it gives me this error. I am using payload 3.0.0-beta.74
Star
Discord
online
Get dedicated engineering support directly from the Payload team.