首页 > 开发环境中的跨域代理用http-proxy-middleware+broswerSync谁用到过?

开发环境中的跨域代理用http-proxy-middleware+broswerSync谁用到过?

开发环境中的跨域代理用http-proxy-middleware+broswerSync+gulp谁用到过?

比如我的本地

有一个3000的服务器,我希望,get
http://10.3.30.182:8999/openr...的时候,代理转发一次,因为直接请求浏览器会跨域。有没有一个完整的配置文件,不用nginx,只是Dev 环境


在服务器端配置CORS


给你一个环境种子,https://github.com/hjzheng/gu...
我在实际项目中用过,里面有http-proxy-middleware 和 broswerSync的用法


  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
  });
【热门文章】
【热门文章】