-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (27 loc) · 862 Bytes
/
server.js
File metadata and controls
37 lines (27 loc) · 862 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
31
32
33
34
35
36
37
const express = require('express');
const morgan = require('morgan');
const helmet = require('helmet');
const cors = require('cors');
const path = require('path');
// bring in the routes
const routes = require('./api/routes');
// create a server
const server = express();
// use json
server.use(express.json());
server.use(morgan('dev'));
server.use(helmet());
// cross origin request sharing permissions
const corsOptions = {
origin: '*',
credentials: true
};
server.use(cors(corsOptions));
// Serve up static client files (in `/client/build` folder) at root endpoint.
// Static files are created by the `heroku-postbuild` script in package.json
// during deployment
server.use(express.static(path.join(__dirname, 'client/build')));
// pass the server to the routes
routes(server);
// export the server to the app
module.exports = server;