BrowserSync - 使用错误的编码进行代理

时间:2016-07-05 08:08:58

标签: javascript browser-sync

我想使用浏览器同步来代理我的远程网站。我的gulp任务如下:

gulp.task('proxy', function() {
  var bs = require('browser-sync');
  var browserSync = bs.create();
  var iconv = require('iconv-lite');

  browserSync.init({
    browser: [],
    proxy: {
      target: proxyUrl,
      proxyReq: [
        function(proxyReq) {
          proxyReq.setHeader('Content-Type', 'text/plain; charset=windows-1250');
        }
      ],
      proxyRes: [
        function(proxyRes, req, res) {
          console.log(proxyRes.headers);
        }
      ]
    },
    // rewriteRules: [
    //   { // enable if you want to use unminified versions of files
    //     match: /\.min/g,
    //     replace: ''
    //   }
    // ],
    serveStatic: ['.', './public/']
  });
});

不幸的是,该网站以windows 1250编码并显示错误。我该怎么办?

0 个答案:

没有答案