-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (32 loc) · 911 Bytes
/
server.js
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
31
32
33
34
35
36
37
38
var express = require('express');
var apiProxy;
var cors = require('cors');
var corsOptions = {
origin: /hackjunction\.com$/
};
if (process.env.NODE_ENV === 'development') {
apiProxy = require('./server/apiProxy');
} else {
apiProxy = require('./build/apiProxy').default;
}
const app = express();
const port = process.env.PORT || 3000;
const public_path = express.static(__dirname + '/public');
const index_path = __dirname + '/public/index.html';
app.use(cors(corsOptions));
app.use(public_path);
app.use('/api', apiProxy);
const register = (req, res) => {
res.redirect('https://register.hackjunction.com');
};
app.use('/apply', register);
app.use('/register', register);
app.get('*', function(request, response) {
response.sendFile(index_path, function(error) {
if (error) {
console.log(error);
}
});
});
app.listen(port);
console.log('Listening at http://localhost:' + port);