Hi. I don't know why it's returning this error as I have a Payload secret key, similar to this?
PS C:\git\WhitePolaroids1> yarn dev yarn run v1.22.19 $ ts-node server.ts [08:29:55] INFO (payload): Starting Payload... unhandledRejection Error: Error: missing secret key. A secret key is needed to secure Payload. at BasePayload.init (C:\git\WhitePolaroids1\node_modules\payload\src\payload.ts:154:13) at getPayload (C:\git\WhitePolaroids1\node_modules\payload\src\payload.ts:407:56) at initHTTP (C:\git\WhitePolaroids1\node_modules\payload\src\initHTTP.ts:25:35) at Payload.init (C:\git\WhitePolaroids1\node_modules\payload\src\index.ts:14:35) at C:\git\WhitePolaroids1\server.ts:14:17 at step (C:\git\WhitePolaroids1\server.ts:123:23) at Object.next (C:\git\WhitePolaroids1\server.ts:64:20) at asyncGeneratorStep (C:\git\WhitePolaroids1\server.ts:13:28) at _next (C:\git\WhitePolaroids1\server.ts:31:17) at C:\git\WhitePolaroids1\server.ts:36:13
I'm using Nextjs custom-server
I think it's working now. My server.ts and .env file had different strings.
I had the same error and was being caused by using an .env.local file instead of a plain .env file.
is there a solution for this?
You figure this out? I've got same issue deploying to Railway, even though all the relevant ENV vars are set.
after making a few minor changes, yeah somehow. and i defined shared variables on railway settings
here is the code block:
(server and config file)
after that i just restart server. and problem solved.
so it is necessary to make settings for different env files.
thats why. 🙂 hope this help
@diasmannheim strange one but will give it a go thanks 🙂
Still doesn't work for me...
I already have the default production environment setup so I just made all my env variables shared and updated the env path with the code you provided. Exact same error as before.
As a last resort, I uploaded my own env file to github. Honestly, I tried many things and lastly, after deleting the docker settings and restarting the server, I triggered it again with the docker config and somehow it was solved. Frankly, I couldn't understand exactly what solved the problem because the logs were not very helpful.
😂 one of those fixes
Thanks i'll keep looking into this and let you know if i find the source of the fix
sorry :/ but good luck