forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (26 loc) · 765 Bytes
/
index.js
File metadata and controls
30 lines (26 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const path = require('path');
const express = require('express');
const compression = require('compression');
const app = express();
const frontend = require('./frontend');
const backend = require('./backend');
const {
apiEndpoint,
credentials,
} = require('../environment');
app.use(compression());
app.use((req, res, next) => {
if (req.hostname === 'algo-visualizer.jasonpark.me') {
res.redirect(301, 'https://algorithm-visualizer.org/');
} else if (credentials && !req.secure) {
res.redirect(301, `https://${req.hostname}${req.url}`);
} else {
next();
}
});
app.get('/robots.txt', (req, res) => {
res.sendFile(path.resolve(__dirname, '..', 'robots.txt'));
});
app.use(apiEndpoint, backend);
app.use(frontend);
module.exports = app;