Proxy for api calls.
This commit is contained in:
parent
017405f751
commit
92e1dcdd3e
40
Gruntfile.js
40
Gruntfile.js
|
@ -57,8 +57,32 @@ module.exports = function (grunt) {
|
||||||
port: 9000,
|
port: 9000,
|
||||||
// Change this to '0.0.0.0' to access the server from outside.
|
// Change this to '0.0.0.0' to access the server from outside.
|
||||||
hostname: 'localhost',
|
hostname: 'localhost',
|
||||||
livereload: 35729
|
livereload: 35729,
|
||||||
|
middleware: function (connect, options) {
|
||||||
|
if (!Array.isArray(options.base)) {
|
||||||
|
options.base = [options.base];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the proxy
|
||||||
|
var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];
|
||||||
|
|
||||||
|
// Serve static files.
|
||||||
|
options.base.forEach(function(base) {
|
||||||
|
middlewares.push(connect.static(base));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Make directory browse-able.
|
||||||
|
var directory = options.directory || options.base[options.base.length - 1];
|
||||||
|
middlewares.push(connect.directory(directory));
|
||||||
|
|
||||||
|
return middlewares;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
proxies: [{
|
||||||
|
context: '/api/',
|
||||||
|
host: '127.0.0.1',
|
||||||
|
port: 8080
|
||||||
|
}],
|
||||||
livereload: {
|
livereload: {
|
||||||
options: {
|
options: {
|
||||||
open: true,
|
open: true,
|
||||||
|
@ -75,14 +99,6 @@ module.exports = function (grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// The node-server settings
|
|
||||||
develop: {
|
|
||||||
server: {
|
|
||||||
file: 'server/main.js',
|
|
||||||
nodeArgs: ['--debug']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Make sure code styles are up to par and there are no obvious mistakes
|
// Make sure code styles are up to par and there are no obvious mistakes
|
||||||
jshint: {
|
jshint: {
|
||||||
options: {
|
options: {
|
||||||
|
@ -353,16 +369,16 @@ module.exports = function (grunt) {
|
||||||
|
|
||||||
grunt.registerTask('serve', function (target) {
|
grunt.registerTask('serve', function (target) {
|
||||||
if (target === 'dist') {
|
if (target === 'dist') {
|
||||||
return grunt.task.run(['build', 'develop', 'connect:dist:keepalive']);
|
return grunt.task.run(['build', 'connect:dist:keepalive']);
|
||||||
}
|
}
|
||||||
|
|
||||||
grunt.task.run([
|
return grunt.task.run([
|
||||||
'clean:server',
|
'clean:server',
|
||||||
'bowerInstall',
|
'bowerInstall',
|
||||||
'concurrent:server',
|
'concurrent:server',
|
||||||
'autoprefixer',
|
'autoprefixer',
|
||||||
|
'configureProxies',
|
||||||
'connect:livereload',
|
'connect:livereload',
|
||||||
'develop',
|
|
||||||
'watch'
|
'watch'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"grunt-autoprefixer": "~0.4.0",
|
"grunt-autoprefixer": "~0.4.0",
|
||||||
"grunt-bower-install": "~1.0.0",
|
"grunt-bower-install": "~1.0.0",
|
||||||
"grunt-concurrent": "~0.5.0",
|
"grunt-concurrent": "~0.5.0",
|
||||||
|
"grunt-connect-proxy": "~0.1.10",
|
||||||
"grunt-contrib-clean": "~0.5.0",
|
"grunt-contrib-clean": "~0.5.0",
|
||||||
"grunt-contrib-compass": "~0.7.2",
|
"grunt-contrib-compass": "~0.7.2",
|
||||||
"grunt-contrib-concat": "~0.3.0",
|
"grunt-contrib-concat": "~0.3.0",
|
||||||
|
|
Loading…
Reference in a new issue