开发环境中的跨域代理用http-proxy-middleware+broswerSync+gulp谁用到过?
比如我的本地
有一个3000的服务器,我希望,get
http://10.3.30.182:8999/openr...的时候,代理转发一次,因为直接请求浏览器会跨域。有没有一个完整的配置文件,不用nginx,只是Dev 环境
开发环境中的跨域代理用http-proxy-middleware+broswerSync+gulp谁用到过?
比如我的本地
有一个3000的服务器,我希望,get
http://10.3.30.182:8999/openr...的时候,代理转发一次,因为直接请求浏览器会跨域。有没有一个完整的配置文件,不用nginx,只是Dev 环境
var server = {
baseDir: baseDir,
routes: routes
};
/*
* You can add a proxy to your backend by uncommenting the line below.
* You just have to configure a context which will we redirected and the target url.
* Example: $http.get('/users') requests will be automatically proxified.
*
* For more details and option, https://github.com/chimurai/http-proxy-middleware/blob/v0.9.0/README.md
*/
server.middleware = [proxyMiddleware(['/api'], {target: 'http://localhost:8080', changeOrigin: true}),
proxyMiddleware(['/upload'], {target: 'http://localhost:8080', changeOrigin: true}),
proxyMiddleware(['/a/login'], {target: 'http://localhost:8080', changeOrigin: true}),
proxyMiddleware(['/a/ajaxlogin'], {target: 'http://localhost:8080', changeOrigin: true}),
proxyMiddleware(['/a/logout'], {target: 'http://localhost:8080', changeOrigin: true})];
browserSync.instance = browserSync.init({
startPath: '/',
server: server,
browser: browser
});大哥,解决了吗?
求方案。
我这样设置实际不行好像。
var middlewares = proxyMiddleware(['/api'], {target: 'http://0.0.0.0:8080', changeOrigin: true});
browserSync({
port: 8888,
ui: {
port: 8889
},
server: {
baseDir: 'src',
middleware: [
middlewares,
...
使用我是data/baggage/getValidateCode.do,
结果404
1 回答851 阅读✓ 已解决
1 回答1.1k 阅读
2 回答773 阅读
2 回答617 阅读
2 回答601 阅读
1 回答698 阅读
1 回答680 阅读
给你一个环境种子,https://github.com/hjzheng/gu...
我在实际项目中用过,里面有http-proxy-middleware 和 broswerSync的用法