In this code
var history = require('connect-history-api-fallback');
var express = require('express');
var path = require('path');
var app = express();
app.use(history({
index: 'Trading Inquiry/index.html'
}));
app.use(express.static(path.join(__dirname, 'Trading Inquiry')));
app.get('/', function (req, res) {
console.log(1);
res.sendFile('Trading Inquiry/index.html');
});
var server = app.listen(process.env.PORT || 3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('My site started at http://%s:%s', host, port);
});
I set it up so that links are relative to the folder Trading Inquiry. Plus ig the / route is given, return the index.html file, and for routes that don't match, then also return the index.html file. However when I visit http://localhost:3000, I get
Cannot GET /
This works though
http://localhost:3000/index.html
Does anyone know what's wrong?
Thanks