DEV Community

Arthuro Ali Gomez
Arthuro Ali Gomez

Posted on

Heroku: Failed to load resource: the server responded with a status of 404 (Not Found) and Cannot GET

I made a MEAN stack project, which works perfectly on my localhost, I have configured everything, I follow tutorials, to put it online with heroku. I add the link of the app so that they can visualize better https://arthuro-gomez-appweb.herokuapp.com/

There you can see the error I get on the console

This is my github repository https://github.com/Emocrat3/Curso-React-Vue-js-Angular where you can see the whole project and can better tell me what it can be, I have tried solutions like removing dist from .gitignore.

To have at a glance the code of my index.js I add it here

'use strict'

var mongoose = require('mongoose');
var app = require('./app.js');
var port = process.env.PORT || 3900;

mongoose.set('useFindAndModify', false);
mongoose.Promise = global.Promise;

mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/api_rest_blog', {
useNewUrlParser: true})
.then(()=> {
console.log('Connection successfully!');

});

app.listen(port, () => {
console.log('Server run in http://localhost:'+port);
});

I also add my app.js

'use strict'

var express = require('express');
var bodyParser = require('body-parser');

var app = express();

var article_routes = require('./routes/article');

// Middlewares

app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());

// CORS
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Authorization, X-API-KEY, Origin, X-Requested-With,
Content-Type, Accept, Access-Control-Allow-Request-Method');
res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE');
res.header('Allow', 'GET, POST, OPTIONS, PUT, DELETE');
next();
});
app.use('/api', article_routes);
module.exports = app;

And this shows my heroku logs

2020-06-28T17:13:27.096713+00:00 heroku[web.1]: Starting process with command node backend/index.js

2020-06-28T17:13:30.478039+00:00 app[web.1]: (node:4) DeprecationWarning: current Server Discovery
and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server
Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient
constructor.

2020-06-28T17:13:30.478050+00:00 app[web.1]: (Use node --trace-deprecation ... to show where the
warning was created)

2020-06-28T17:13:30.478426+00:00 app[web.1]: Server run in http://localhost:11223
2020-06-28T17:13:30.566999+00:00 app[web.1]: Connection successfully!

2020-06-28T17:13:31.524077+00:00 heroku[web.1]: State changed from starting to up

2020-06-28T17:13:44.010099+00:00 heroku[router]: at=info method=GET path="/" host=arthuro-gomez-
appweb.herokuapp.com request_id=9787f2cd-9af6-47e8-aa52-a523df220b2c fwd="190.161.220.127" dyno=web.1
connect=1ms service=9ms status=404 bytes=659 protocol=https

2020-06-28T17:18:14.124368+00:00 heroku[router]: at=info method=GET path="/" host=arthuro-gomez-
appweb.herokuapp.com request_id=2afe9929-f1e0-4be0-a689-c1d88ca080b4 fwd="190.161.220.127" dyno=web.1
connect=0ms service=3ms status=404 bytes=659 protocol=https

2020-06-28T17:31:04.328012+00:00 heroku[router]: at=info method=HEAD path="/"
host=arthuro-gomez-appweb.herokuapp.com request_id=aed274b1-4a12-4dac-84d0-
de41cd475687 fwd="217.182.175.162" dyno=web.1 connect=3ms service=2ms
status=404 bytes=520 protocol=https

Top comments (0)