Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

315
Vistas
How can I fix this cannot get error in Heroku?

I'm trying to deploy my app to Heroku, it runs fine locally. I'm getting the error in the logs after the build:

heroku[router]: at=info method=GET path="/" host=appname.herokuapp.com  fwd="xx.xxx.xxx.xxx" dyno=web.1 connect=0ms service=8ms status=404 bytes=415 protocol=https

When trying to view the app I get the cannot GET / error, I've looked through a bunch of similar errors & can't find where I'm going wrong.my app.js file is located at ./server/app.js

app.js

const express = require("express");
const http = require("http");
var cors = require("cors");
const morgan = require("morgan");
const bodyParser = require("body-parser");
const path = require("path");
const mongoose = require("mongoose");
const createError = require("http-errors");
const { Router } = require("express");
let codeRoutes = require("./api/code-routes.js");
/**
 * App configurations
 */
let app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(morgan("dev"));
app.use(cors());
app.use(express.static(path.join(__dirname, "../dist/my-app")));
app.use(
  "/",
  express.static(path.join(__dirname, "../dist/my-app"))
);
/**
 * Variables
 */

const MONGODB_URI =
  "myMongoDBConnString";

/**
 * Database connection
 */
mongoose
  .connect(MONGODB_URI, {
    promiseLibrary: require("bluebird"),
    useUnifiedTopology: true,
    useNewUrlParser: true,
  })
  .then(() => {
    console.debug(`Connection to the database instance was successful`);
  })
  .catch((err) => {
    console.log(`MongoDB Error: ${err.message}`);
  }); // end mongoose connection

app.use("/api", myApi);

app.listen(process.env.PORT || 3000, function () {
  console.log("Application is running at localhost:" + app.get("port"));
});

package.json

{
  "name": "myapp",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "node ./server/app.js",
    "server": "nodemon ./server/app.js",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "localhost": "ng build && node ./server/app.js"
  },
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda