0

I have a vuejs app which set up with vue cli, and i'm trying deploy my app to heroku.

Here's my server :

const express = require('express');
const port = process.env.PORT || 8080;

const app = express();

app.use(express.static(__dirname + "/dist/"));
app.get(/.*/ , function(req,res) {
  res.sendfile(__dirname + "/dist/index.html");
});

app.listen(port);

console.log("Server started..."); 

  • I remove dist from gitignore,
  • I aded a start point like "start": "node server.js" in package.json

Here's what i see on console :

Failed to load resource: the server responded with a status of 503 (Service Unavailable) /favicon.ico:1

Here's heroku logs :

2019-12-13T08:55:49.464914+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=followgoals.herokuapp.com request_id=09df33ae-96ab-415a-929b-530fb943318d fwd="37.130.123.179" dyno= connect= service= status=503 bytes= protocol=https 2019-12-13T08:55:49.828341+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=followgoals.herokuapp.com request_id=21de7307-502e-4104-a648-8e6b0832a3fe fwd="37.130.123.179" dyno= connect= service= status=503 bytes= protocol=https

So what can i do the fix problem ?

4
  • It looks like your express server is crashing. Does it run fine on your local machine? Commented Dec 13, 2019 at 9:49
  • Yes it does, no problem on local. Commented Dec 13, 2019 at 10:12
  • How have you deployed the app? Since your server.js is pretty short, the only possible issues I can think of are (1) node dependencies (express) not installed, or (2) the /dist/ directory or /dist/index.html do not exist. Commented Dec 15, 2019 at 15:42
  • Actually i missed that npm does not build index.html file in dist folder and server wait for that as you said, this was problem, but i added index.html file in dist folder with a plug-in, but still app does not work on Heroku also local. I got an error en heroku like that : Failed to load resource: the server responded with a status of 503 (Service Unavailable) Thank for your help. Commented Dec 17, 2019 at 12:38

1 Answer 1

1

I had the same problem, worked on local, 503 error on heroku, and I fixed it by going to my db cloud service(mongodb atlas), and changed the white list setting on my cluster from "home" to "anywhere".

https://www.youtube.com/watch?v=leNNivaQbDY&t=31s

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.