Java 如何根据特定路径更改gulp端口
我是gulp的新手我在应用程序中使用gelp服务器,我在端口8080上安装了一个java服务器我想在另一个项目中使用oAuth2进行身份验证我使用grunt,这是我如何将用户重定向到oAuth2的 这是我的Grunfile代码Java 如何根据特定路径更改gulp端口,java,angularjs,gruntjs,gulp,Java,Angularjs,Gruntjs,Gulp,我是gulp的新手我在应用程序中使用gelp服务器,我在端口8080上安装了一个java服务器我想在另一个项目中使用oAuth2进行身份验证我使用grunt,这是我如何将用户重定向到oAuth2的 这是我的Grunfile代码 connect: { options: { port: 9000, // Change this to '0.0.0.0' to access the server from outside. hostname: 'localhost',
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
}, proxies: [
{
context: [
'/_ah',
'/secured',
'/oauth2login',
'/oauth2callback'
],
host: 'localhost',
port: 8080,
https: false,
changeOrigin: false,
xforward: false
}
]
}
现在我想在gulp上做同样的事情,这里是我的gulpfile.js代码
var options = {
port: 3000,
ghostMode: {
clicks: false,
location: false,
forms: false,
scroll: true
},
injectChanges: true,
logFileChanges: true,
logLevel: 'debug',
logPrefix: 'gulp-patterns',
notify: true,
reloadDelay: 0, //1000,
online: false,
proxies: [
{
context: [
'/_ah',
'/secured',
'/oauth2login',
'/oauth2callback'
],
host: 'localhost',
port: 8080,
https: false,
changeOrigin: false,
xforward: false
}
]
};
我添加了代理,但没有工作。我想这样做,因为在我的app.run中,我想使用oAuth2对用户进行身份验证
这是我的应用程序
app.run(function($rootScope, datastoreUser){
datastoreUser.LoginUser("me").then(function(result){
console.log("User is authenticated");
console.log(result);
},function(error){
console.log("An error occured user is not authenticated");
console.log(error);
window.location.href = '/oauth2login';
})
})
如果有人需要我的问题,我找到了解决办法 我在这里添加了http代理中间件模块代码
var proxyMiddleware = require('http-proxy-middleware');
var options = {
port: 3000,
ghostMode: {
clicks: false,
location: false,
forms: false,
scroll: true
},
injectChanges: true,
logFileChanges: true,
logLevel: 'debug',
logPrefix: 'gulp-patterns',
notify: true,
reloadDelay: 0, //1000,
online: false
};
function serveApp() {
gulp.watch([config.sass], ['sass']);
options.server = {
baseDir: [
config.client,
config.tmp
]
};
options.files = [
config.client + '/**/*.*',
'!' + config.sass,
config.tmp + '/**/*.css'
];
options.middleware = proxyMiddleware([
'/_ah',
'/secured',
'/oauth2login',
'/oauth2callback'
],
{
target: 'http://localhost:8080'
});
browserSync(options);
}