Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5060

Heroku deployment error - AssertionError [ERR_ASSERTION]: HOST is required

$
0
0

I am searching for help since I got stuck for over two weeks with a deploy provblem. I am a junior developer and I would highly appreciate your help.

I am trying to deploy a react app with node.js server to heroku.The simplified project root folder structure is:

Project |+-- client (a react project initiated by create-react) |  |   |  +-- src+-- index.js (a server file) |+-- config.js |   +--.env |+-- procfile

Locally everything works fine.Root package.json scripts:

{"name": "firebase-api","version": "1.0.0","node": "v16.14.0","license": "MIT","scripts": {"start":"node index.js","start:server": "node index.js","dev:server": "nodemon index.js","start:client": "cd client && yarn start","heroku-postbuild":"cd client && yarn && yarn build","dev":"concurrently --kill-others-on-fail  \"yarn dev:server\" \"yarn start:client\""  },

procfile content:web : npm run start

Each time i try to deploy to heroku, initially i get information tha built is sucessful but the app is not working. Upon writing heroku logs --tail i get this error:

2022-08-20T20:33:06.206918+00:00 heroku[web.1]: Starting process with command `npm start`2022-08-20T20:33:07.889702+00:00 app[web.1]:2022-08-20T20:33:07.889715+00:00 app[web.1]: > firebase-api@1.0.0 start2022-08-20T20:33:07.889716+00:00 app[web.1]: > node index.js2022-08-20T20:33:07.889716+00:00 app[web.1]:2022-08-20T20:33:08.051147+00:00 app[web.1]: node:assert:4002022-08-20T20:33:08.051148+00:00 app[web.1]: throw err;2022-08-20T20:33:08.051148+00:00 app[web.1]: ^2022-08-20T20:33:08.051148+00:00 app[web.1]:2022-08-20T20:33:08.051149+00:00 app[web.1]: AssertionError [ERR_ASSERTION]: HOST is required2022-08-20T20:33:08.051149+00:00 app[web.1]: at Object.<anonymous> (/app/config.js:32:1)2022-08-20T20:33:08.051150+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1126:14)2022-08-20T20:33:08.051150+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)2022-08-20T20:33:08.051150+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:1004:32)2022-08-20T20:33:08.051150+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:839:12)2022-08-20T20:33:08.051151+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1028:19)2022-08-20T20:33:08.051152+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)2022-08-20T20:33:08.051152+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:10:16)2022-08-20T20:33:08.051153+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1126:14)2022-08-20T20:33:08.051153+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) {2022-08-20T20:33:08.051154+00:00 app[web.1]: generatedMessage: false,2022-08-20T20:33:08.051154+00:00 app[web.1]: code: 'ERR_ASSERTION',2022-08-20T20:33:08.051154+00:00 app[web.1]: actual: undefined,2022-08-20T20:33:08.051154+00:00 app[web.1]: expected: true,2022-08-20T20:33:08.051154+00:00 app[web.1]: operator: '=='2022-08-20T20:33:08.051155+00:00 app[web.1]: }2022-08-20T20:33:08.184195+00:00 heroku[web.1]: Process exited with status 12022-08-20T20:33:08.589558+00:00 heroku[web.1]: State changed from starting to crashed2022-08-20T20:33:08.592656+00:00 heroku[web.1]: State changed from crashed to starting2022-08-20T20:33:20.256482+00:00 heroku[web.1]: Starting process with command `npm start`2022-08-20T20:33:21.869414+00:00 app[web.1]: 2022-08-20T20:33:21.869431+00:00 app[web.1]: > firebase-api@1.0.0 start2022-08-20T20:33:21.869432+00:00 app[web.1]: > node index.js2022-08-20T20:33:21.869432+00:00 app[web.1]:2022-08-20T20:33:21.992981+00:00 app[web.1]: node:assert:4002022-08-20T20:33:21.992983+00:00 app[web.1]: throw err;2022-08-20T20:33:21.992983+00:00 app[web.1]: ^2022-08-20T20:33:21.992983+00:00 app[web.1]:2022-08-20T20:33:21.992984+00:00 app[web.1]: AssertionError [ERR_ASSERTION]: HOST is required2022-08-20T20:33:21.992984+00:00 app[web.1]: at Object.<anonymous> (/app/config.js:32:1)2022-08-20T20:33:21.992985+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1126:14)2022-08-20T20:33:21.992985+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)2022-08-20T20:33:21.992985+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:1004:32)2022-08-20T20:33:21.992986+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:839:12)2022-08-20T20:33:21.992986+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1028:19)2022-08-20T20:33:21.992986+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)2022-08-20T20:33:21.992986+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:10:16)2022-08-20T20:33:21.992987+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1126:14)2022-08-20T20:33:21.992987+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) {2022-08-20T20:33:21.992988+00:00 app[web.1]: generatedMessage: false,2022-08-20T20:33:21.992988+00:00 app[web.1]: code: 'ERR_ASSERTION',2022-08-20T20:33:21.992988+00:00 app[web.1]: actual: undefined,2022-08-20T20:33:21.992988+00:00 app[web.1]: expected: true,2022-08-20T20:33:21.992988+00:00 app[web.1]: operator: '=='2022-08-20T20:33:21.992989+00:00 app[web.1]: }2022-08-20T20:33:22.128683+00:00 heroku[web.1]: Process exited with status 12022-08-20T20:33:22.202774+00:00 heroku[web.1]: State changed from starting to crashed2022-08-20T20:33:24.161237+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dulin-dis.herokuapp.com request_id=ca6bea64-3bbc-46c1-90ac-4f3247b0149e fwd="78.11.194.212" dyno= connect= service= status=503 bytes= protocol=https2022-08-20T20:33:24.792296+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dulin-dis.herokuapp.com request_id=2fa74bad-63c7-46f1-8179-73e1026bd3e1 fwd="78.11.194.212" dyno= connect= service= status=503 bytes= protocol=https2022-08-20T20:34:13.000000+00:00 app[api]: Build succeeded2022-08-20T20:34:24.374479+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=dulin-dis.herokuapp.com request_id=c3c6b80a-df79-4dc2-8b4f-34bf78acdd50 fwd="78.11.194.212" dyno= connect= service= status=503 bytes= protocol=https2022-08-20T20:34:24.583983+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=dulin-dis.herokuapp.com request_id=6d89eda6-d2ac-48aa-9a7f-3a1b9496e7a9 fwd="78.11.194.212" dyno= connect= service= status=503 bytes= protocol=https

I am using .env and config to set POST and HOST in my express server

const HOST = process.env.HOST || config.app.host;

I know that heroku puts its own PORT for the webapp, hence we dont add it inside config vars in heroku project. I just set there other config vars that i have in my config file, like API keys.

Why do I get an error that HOST is required? Isn't it one of the config vars that heroku should set at an environment variable on it site? How to fix the issue?I would really appreciate your hints.Best regards


Viewing all articles
Browse latest Browse all 5060


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>