I have angular 6 app in my local machine , everything works perfectly as I want, after finishing the project I deployed it to heroku, when I run my app here is the link to the app in heroku :Testing App
as you can see I get the following error in console browser
Failed to load resource: the server responded with a status of 404 (Not Found)
- Here is my app structure in github
for quick reference , Here is server.js
const express = require('express'); const bodyParser = require('body-parser'); const cors = require('cors'); const path = require('path'); const app = express(); const port = process.env.PORT || 3000 app.use(express.static(path.join(__dirname, '/majeni/dist/majeni/'))); app.use(bodyParser.json()); app.use(cors()); const forceSSL = function () { return function (req, res, next) { if (req.headers['x-forwarded-proto'] !== 'https') { return res.redirect( ['https://', req.get('Host'), req.url].join('') ); } next(); }}app.use(forceSSL()); app.get('/*', function (req, res) { res.sendFile(path.join(__dirname + '/majeni/dist/majeni/index.html')); }); app.listen(port, () => { console.log('Server started on port '+port); });
Here is heroku logs.
2018-08-16T17:46:38.891333+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/majeni/dist/majeni/index.html'
What is wrong with my code?
dist
directory? – user184994dist
directory in your checked in code – user184994ng-build
i rungit push heroku master
– The Dead Mandist
directory is in your.gitignore
, so it's not being committed. The best option is to provide apostinstall
script that builds your project devcenter.heroku.com/articles/… – user184994