Having trouble setting up an express + angular app.
Successfully loaded the assets files into it.
Upon examining my code for Express and the html file, it seems that Express is only returning the index.html file, causing all routes to return that file.
Below is the code for Express:
//server.js
// set up ========================
var express = require('express'),
bodyParser = require('body-parser'),
morgan = require('morgan'),
path = require('path'),
app = express(),
mongoose = require('mongoose'),
jwt = require('jsonwebtoken'), // used for token operations
config = require('./config'), // obtain config file
User = require('./model/users'), //mongo model
routes = require('./middleware/routes');
// configuration =================
app.use(express.static('/client'));
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({'extended':'true'});
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/json' }));
mongoose.connect(config.database);
app.set('superPin', config.secret);
// start server =================
//
app.listen(8080);
console.log('App started and is listening on port 8080');
//
app.get('/checkServer', function(request,response){
response.send('Works fine. Server started at default get routing to check if server runs.');
});
//
app.get('*',function(request,response){
response.sendFile(path.resolve('../client/view/index.html'));
});
//
and here is my index.html file:
<!DOCTYPE html>
<html>
<head>
<title>My Angular App</title>
</head>
<body ng-app="pmt">
<div ng-view></div>
<script src="client/assets/vendor/angular/angular.min.js"></script>
<script src="client/assets/vendor/angular-bootstrap/ui-bootstrap.min.js"></script>
<script src="client/assets/vendor/angular-message/angular-message.min.js"></script>
<script src="client/assets/vendor/angular-touch/angular-touch.min.js"></script>
<script src="client/assets/vendor/angular-ui-router/angular-ui-router.min.js"></script>
<script src="client/assets/vendor/angular-touch/angular-touch.min.js"></script>
<script src="client/assets/vendor/moment/min/moment.min.js"></script>
<script src="client/controller/routes.js"></script>
</body>
</html>
Attached is a print screen of my folder structure: https://i.sstatic.net/hfxvv.png
And here is the link to the repository: https://bitbucket.org/cojok/pmt/
Despite searching through related posts, I am unable to pinpoint what I may be doing wrong.
Encountering this error in the browser https://i.sstatic.net/pOmIK.png