@@ -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 = / \/ p r o x y \/ p r o x y .a s h x / 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 : {
0 commit comments