Proxy for api calls.
This commit is contained in:
parent
017405f751
commit
92e1dcdd3e
2 changed files with 29 additions and 12 deletions
40
Gruntfile.js
40
Gruntfile.js
|
@ -57,8 +57,32 @@ module.exports = function (grunt) {
|
|||
port: 9000,
|
||||
// Change this to '0.0.0.0' to access the server from outside.
|
||||
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: {
|
||||
options: {
|
||||
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
|
||||
jshint: {
|
||||
options: {
|
||||
|
@ -353,16 +369,16 @@ module.exports = function (grunt) {
|
|||
|
||||
grunt.registerTask('serve', function (target) {
|
||||
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',
|
||||
'bowerInstall',
|
||||
'concurrent:server',
|
||||
'autoprefixer',
|
||||
'configureProxies',
|
||||
'connect:livereload',
|
||||
'develop',
|
||||
'watch'
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"grunt-autoprefixer": "~0.4.0",
|
||||
"grunt-bower-install": "~1.0.0",
|
||||
"grunt-concurrent": "~0.5.0",
|
||||
"grunt-connect-proxy": "~0.1.10",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
"grunt-contrib-compass": "~0.7.2",
|
||||
"grunt-contrib-concat": "~0.3.0",
|
||||
|
|
Loading…
Reference in a new issue