Skip to content

Commit 03088a5

Browse files
authored
Merge pull request #669 from cmv/fix/updated-grunt-connect-with-proxy
Updated grunt connect with proxy
2 parents c7f1d76 + caeba31 commit 03088a5

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

Gruntfile.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ module.exports = function (grunt) {
44
// middleware for grunt.connect
55
var middleware = function (connect, options, middlewares) {
66
// inject a custom middleware into the array of default middlewares for proxy page
7+
var bodyParser = require('body-parser');
78
var proxypage = require('proxypage');
89
var proxyRe = /\/proxy\/proxy.ashx/i;
910

1011
var enableCORS = function (req, res, next) {
11-
res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
12+
res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*');
1213
res.setHeader('Access-Control-Allow-Credentials', true);
1314
res.setHeader('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE');
14-
res.setHeader('Access-Control-Allow-Headers', req.headers['access-control-request-headers']);
15+
res.setHeader('Access-Control-Allow-Headers', req.headers['access-control-request-headers'] || 'Origin, X-Requested-With, Content-Type, Accept');
1516
return next();
1617
};
1718

@@ -24,8 +25,8 @@ module.exports = function (grunt) {
2425

2526
middlewares.unshift(proxyMiddleware);
2627
middlewares.unshift(enableCORS);
27-
middlewares.unshift(connect.json()); //body parser, see https://github.com/senchalabs/connect/wiki/Connect-3.0
28-
middlewares.unshift(connect.urlencoded()); //body parser
28+
middlewares.unshift(bodyParser.json()); //body parser, see https://github.com/senchalabs/connect/wiki/Connect-3.0
29+
middlewares.unshift(bodyParser.urlencoded({extended: true})); //body parser
2930
return middlewares;
3031
};
3132

@@ -124,6 +125,8 @@ module.exports = function (grunt) {
124125
port: 3000,
125126
base: 'viewer',
126127
hostname: '*',
128+
protocol: 'https',
129+
keepalive: true,
127130
middleware: middleware
128131
}
129132
},
@@ -132,16 +135,18 @@ module.exports = function (grunt) {
132135
port: 3001,
133136
base: 'dist/viewer',
134137
hostname: '*',
138+
protocol: 'https',
139+
keepalive: true,
135140
middleware: middleware
136141
}
137142
}
138143
},
139144
open: {
140145
'dev_browser': {
141-
path: 'http://localhost:3000/index.html'
146+
path: 'https://localhost:3000/index.html'
142147
},
143148
'build_browser': {
144-
path: 'http://localhost:3001/index.html'
149+
path: 'https://localhost:3001/index.html'
145150
}
146151
},
147152
compress: {

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33
"version": "2.0.0-beta.1",
44
"author": "cmv.io - https://github.com/cmv/",
55
"license": "MIT",
6-
"year": "2016",
7-
"homepage": "http://cmv.io/",
6+
"year": "2017",
7+
"homepage": "https://cmv.io/",
88
"repository": "https://github.com/cmv/cmv-app/",
99
"dependencies": {
10-
"babel-eslint": "6.1.x",
10+
"babel-eslint": "~7.1.1",
1111
"csslint": "1.0.x",
1212
"eslint": "3.5.x",
1313
"grunt": "1.0.x",
1414
"grunt-contrib-clean": "1.0.x",
15-
"grunt-contrib-compress": "1.3.x",
15+
"grunt-contrib-compress": "~1.4.1",
1616
"grunt-contrib-connect": "1.0.x",
1717
"grunt-contrib-copy": "1.0.x",
18-
"grunt-contrib-csslint": "1.0.x",
18+
"grunt-contrib-csslint": "~2.0.x",
1919
"grunt-contrib-cssmin": "1.0.x",
20-
"grunt-contrib-uglify": "2.0.x",
20+
"grunt-contrib-uglify": "2.1.x",
2121
"grunt-contrib-watch": "1.0.x",
2222
"grunt-eslint": "19.0.x",
2323
"grunt-newer": "1.2.x",
2424
"grunt-open": "0.2.x",
2525
"grunt-postcss": "0.8.x",
26+
"body-parser": "1.16.x",
2627
"proxypage": "*"
2728
},
2829
"engine": "node >= 4",

0 commit comments

Comments
 (0)