问题:
我正在尝试将我的 grunt 服务器连接到在端口 8080 上运行的 api 服务。
问题:
:9000/secured/api/users/portal/me Failed to load resource: the server responded with a status of 503 (Service Unavailable)
我认为即使'configureProxies:server'
应用程序没有将请求重定向到好的服务器。
我的控制台:运行命令后grunt
Running "sass:dist" (sass) task
Running "copy:dev" (copy) task
Copied 80 files
Running "clean:server" (clean) task
>> 0 paths cleaned.
Running "wiredep: app" (wiredep) task
Running "configureProxies:server" (configureProxies) task
Proxy created for: /_ah,/secured,/oauth2login,/oauth2callback to localhost:8080
Running "connect:livereload" (connect) task
Started connect web server on http://localhost:9000
Running "watch" task
Waiting...
我的 Gruntfile.js:
require('load-grunt-tasks')(grunt);
var pkg = grunt.file.readJSON('package.json');
grunt.loadNpmTasks('grunt-connect-proxy');
var serveStatic = require('serve-static');
var serveIndex = require('serve-index');
var options = {
...
connect: {
options: {
livereload: true,
hostname: 'localhost',
base: 'app',
port: 9000
},
proxies: [
{
context: [
'/_ah',
'/secured',
'/oauth2login',
'/oauth2callback'
],
host: 'localhost',
port: 8080,
https: false,
changeOrigin: false,
xforward: false
}
],
livereload: {
options: {
open: true,
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(serveStatic(base));
});
// Make directory browse-able.
var directory = options.directory || options.base[options.base.length - 1];
middlewares.push(serveIndex(directory));
return middlewares;
}
}
}
...
}
var configs = require('load-grunt-configs')(grunt, options);
// Define the configuration for all the tasks
grunt.initConfig(configs);
grunt.registerTask('bumper', ['bump-only']);
grunt.registerTask('css', ['sass']);
grunt.registerTask('default', [
'sass',
'copy:dev',
'clean:server',
'wiredep',
'configureProxies:server',
'connect:livereload',
'watch'
]);
我的期望:
当我向以下路径发出请求时,"/_ah,/secured,/oauth2login,/oauth2callback"
它应该将请求重定向到'localhost:8080'
它仍然请求的问题'localhost:9000