-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (32 loc) · 815 Bytes
/
server.js
File metadata and controls
42 lines (32 loc) · 815 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
38
39
40
41
42
/**
* Development server
* ------------------
* Build is on port 3001
*/
const express = require('express');
/**
* Environment / configuration
*/
const portBuild = 3001;
/**
* Create our express app
*/
const build = express();
/**
* Accept browser requests for assets
*/
build.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
/**
* Start build and assets folders
*/
if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'staging') {
build.use(express.static(`${__dirname}/assets`));
build.use(express.static(`${__dirname}/dist`));
build.listen(portBuild, () => {
console.log(`🔨 Build bundles is on port ${portBuild}`);
});
}