3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 var express
= require('express');
20 var path
= require('path');
21 var httpProxy
= require('http-proxy');
22 var bodyParser
= require('body-parser');
23 var cors
= require('cors');
24 var session
= require('express-session');
25 var proxy
= httpProxy
.createProxyServer();
28 var isProduction
= process
.env
.NODE_ENV
=== 'production';
29 var port
= isProduction
? 8080 : 8888;
30 var publicPath
= path
.resolve(__dirname
, 'public');
34 //Routes for local development
35 var lpRoutes
= require('./routes.js');
37 app
.use(express
.static(publicPath
));
39 secret
: 'ritio rocks',
41 app
.use(bodyParser
.urlencoded({
44 app
.use(bodyParser
.json());
46 app
.use('/', lpRoutes
);
47 var bundle
= require('./server/bundle.js');
50 app
.all('/build/*', function (req
, res
) {
52 target
: 'http://localhost:8080'
57 proxy
.on('error', function(e
) {
58 console
.log('Could not connect to proxy, please try again...');
61 app
.listen(port
, function () {
62 console
.log('Server running on port ' + port
);