我有一个angularJs应用程序,我用grunt构建,服务器后端用Java编写,运行在tomcat服务器上.在开发时我想要使用grunt-connect-proxy连接它们.但我甚至无法让它工作.
我在网上找到的所有"示例"和"演示"都使用了几百行Gruntfile.js.结果证明找不到问题并不是很有用.什么是一个最小的(!),例如什么样子的?
如何使用webpack-dev-server 实现'proxy'(类似于grunt-connect-proxy)选项?
我正在使用webpack和webpack-dev-server与Grunt.Gruntfile.js(代码下面)中的任务能够在端口8080上启动服务器.我想为所有后端数据请求添加代理设置(上下文URL/ajax/*).
"webpack-dev-server": {
options: {
webpack: webpackConfig,
publicPath: "/src/assets"
},
start: {
keepAlive: true,
watch: true
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用grunt-connect-proxy "^ 0.2.0"来代理我的angularjs应用程序中的api.该项目由yeoman角度发电机启动.
Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:9000/api/users
Run Code Online (Sandbox Code Playgroud)
我的代理配置:
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
proxies: [{
context: '/api', // the context of the data service
host: 'localhost', // wherever the data service is running
port: 8080, // the port that the data service is running on
https: …
Run Code Online (Sandbox Code Playgroud) 问题:
我正在尝试将我的grunt服务器连接到在端口8080上运行的api服务.
问题:
:9000/secured/api/users/portal/me Failed to load resource: the server responded with a status of 503 (Service Unavailable)
Run Code Online (Sandbox Code Playgroud)
我认为即使'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...
Run Code Online (Sandbox Code Playgroud)
我的Gruntfile.js:
require('load-grunt-tasks')(grunt);
var pkg = grunt.file.readJSON('package.json');
grunt.loadNpmTasks('grunt-connect-proxy');
var …
Run Code Online (Sandbox Code Playgroud)