You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/react/server.js

18 lines
530 B

const express = require('express');
const path = require('path');
const port = process.env.PORT || 8808;
const app = express();
// the __dirname is the current directory from where the script is running
app.use(express.static(path.resolve(__dirname, 'dist')));
// send the user to index html page inspite of the url
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'index.html'));
});
app.listen(port, () => {
// eslint-disable-next-line no-console
console.log('App listening on port:', port);
});