node-express-realworld-example-app icon indicating copy to clipboard operation
node-express-realworld-example-app copied to clipboard

Deployment on Heroku did not work

Open arrowwu opened this issue 7 years ago • 15 comments

I deployed from both windows and mac, all seemed to work fine, but when i open the app from Heroku, it says Application error

arrowwu avatar Jun 11 '17 04:06 arrowwu

Also 'heroku addons:create mongolabs:sandbox' should be mongolab (without s)

arrowwu avatar Jun 13 '17 04:06 arrowwu

can someone help us find a solution for this ?

oussamajabnouni avatar Jun 14 '17 13:06 oussamajabnouni

anyone here? Please help!

arrowwu avatar Jun 19 '17 22:06 arrowwu

i got this working by seeing heroku logs and fixing them

oussamajabnouni avatar Jun 22 '17 00:06 oussamajabnouni

can you share more info? What did you do to fix it?

arrowwu avatar Jun 22 '17 01:06 arrowwu

open the heroku link then type heroku logs read the error find them in code and fix them for me errors was es6 syntax problem

oussamajabnouni avatar Jun 22 '17 11:06 oussamajabnouni

Thanks, the error i saw on the logs is "Secret should be set",

in index.js, if i change this line: secret: process.env.NODE_ENV === 'production' ? process.env.SECRET : 'secret' to: secret: process.env.NODE_ENV === 'production' ? 'secretforproduct' : 'secret'

Then it works, but that is not good for production.

It looks like it can get process.env.SECRET?

arrowwu avatar Jun 26 '17 23:06 arrowwu

Hey, i think you should change the 'secret' not process.env.SECRET

oussamajabnouni avatar Jun 27 '17 01:06 oussamajabnouni

I had the same error. I created a Heroku environment variable SECRET and set it to whatever I wanted the secret to be.

heroku config:set SECRET=canbeanythingyouwant

then test in Postman, it works

ghost avatar Sep 19 '17 22:09 ghost

You need to set(CREATE) the environment variable in heroku "SECRET" to secret.

You can do this via heroku settings or using heroku config command

winston1017 avatar Nov 23 '17 05:11 winston1017

thanks guys

arrowwu avatar Jan 21 '18 02:01 arrowwu

I am trying to deploy to heroku, But I am having problem... Has anyone completed deploying heroku?

wilfredonoyola avatar Aug 28 '19 17:08 wilfredonoyola

@wilfredonoyola I just deployed to heroku successfully. I had to update the SECRET variable as mentioned above by a few people. I ran "heroku config:set SECRET=canbeanythingyouwant" and worked perfectly after the change

sergioc32 avatar Feb 23 '20 19:02 sergioc32

Here's a working backend + frontend deployment of this repo with mongodb ported to sequelize postgresql: https://github.com/cirosantilli/node-express-sequelize-realworld-example-app

Source at: https://github.com/cirosantilli/node-express-sqeuelize-realworld-example-app/tree/7b208085f88375291e2dabcab74229e703cb8769 which is a small fork of https://github.com/sigoden/node-express-realworld-example-app that did the port.

cirosantilli avatar Apr 25 '21 15:04 cirosantilli

What I've found is sometimes a .env secret stored like this locally:

TEST_SECRET=k&2jd!Dj$

will read as a different value when put into Heroku's env boxes like this:

Left box: TEST_SECRET, Right box: k&2jd!Dj$.

What worked for me? Adding quotes around the Heroku env right textbox like so:

Left box: TEST_SECRET, Right box: "k&2jd!Dj$".

mattrltrent avatar May 16 '23 00:05 mattrltrent