Heroku, simple deployment guide #473
quornik
started this conversation in
Show and tell
Replies: 2 comments 2 replies
-
Awesome post @quornik 🙌 We can look into officially documenting this process. This will help a lot in that effort 👍 |
Beta Was this translation helpful? Give feedback.
2 replies
-
Thanks a lot, man! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Simple guidelines how to deploy PayloadCMS to Heroku (TYPESCRIPT)
Because as you might find further down in this note, I was a bit confused how to deploy PayloadCMS to Heroku, then I went thru the process and decided to share few important highlights, for others to avoid struggle and confusion:
TASK
Important, Heroku specific details
PORT
.serve
script command, but it does recognizestart
, so for Heroku purpose, you need the latter doing (almost) exactly the same as former.serve
provided by basic PayloadCMS, there is a series of important deploy changed to ENV_VARS, executed with the use ofcross-env
. But,cross-env
is devDependency, and as such is omitted by Heroku duringstart
. So simple copy / paste of the same command form one to another will not do the trick.Final changes
/src/server.ts
CHANGE
TO
/package.json script should contain "start" like this:
AND for this to work, you need these Enviroment Variables set accordingly in Heroku app:
The domain / serverURL
Next, You want to change the
serverURL
in /src/payload.config.ts | /payload.config.js for it to contain your production domain. ( this part is equally related to typescript nd javascript installation)http://localhost:3000
.PAYLOAD_PUBLIC_
. It is ONLY for the payload.config.js | payload.config.ts files, for server.js | server.ts it is not necessery.Final changes
/env.payload.config.ts
And of course the Enviroment Variable on heroku:
Note: In my installation Admins collection is the one containing administrators. Be not confused, if your standard PayloadCMS config has users in this place.
In this setup I also put trustProxy to true, and cors to all, for testing purposes. Since Heroku works in dynamic enviroments, truspProxy propably is necessery, but if you find your installation working without it, please be kind and make note about it.
DISCLAIMER: This guide is typescript related. Deploying with javascript version of Payload installation is much simpler, and consist only of changes to package.json and adding script:
"start": "node server.js"
and adding ENV_VAR on HerokuNODE_ENV=production
. DO NOT add the second var, as it will crash the build.Thats it. Enjoy!
Here's a part om my original note in this thread:
Can anyone share or maybe point me in to right direction which I should look into: A comprehensive guide to Payload CMS production deployment, on services like Heroku or Netlify?
(...)
I would really appriciate somew help.
Beta Was this translation helpful? Give feedback.
All reactions