Skip to content

REQ and USER are undefined running behind nginx proxy #663

Answered by gonzam88
gonzam88 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks @jmikrut I finally found the error on my side. Given I was using a reverse proxy I thought the Payload serverUrl still had to be localhost:1337. For anyone reading, given the way I configured my payload.config.js, this is the .env that finally worked for me, pay attention to PAYLOAD_PUBLIC_SERVER_URL and PAYLOAD_PUBLIC_PORT

Production Deploy .env

MONGODB_URI=mongodb://user:pass@127.0.0.1:27017/db?authSource=admin
PAYLOAD_SECRET=MYSECRET
PAYLOAD_CONFIG_PATH=src/payload.config.js
PAYLOAD_PUBLIC_SERVER_URL=https://mysite.com
PAYLOAD_PUBLIC_PORT=1336
PAYLOAD_PUBLIC_DEBUG=FALSE
NODE_ENV=PRODUCTION

Local development .env

MONGODB_URI=mongodb://user:pass@127.0.0.1:27017/db?authSource=admi…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jmikrut
Comment options

@gonzam88
Comment options

Comment options

You must be logged in to vote
1 reply
@gonzam88
Comment options

Comment options

You must be logged in to vote
1 reply
@jmikrut
Comment options

Answer selected by gonzam88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants