Grunt-connect-proxy,转发文件不起作用

时间:2015-06-20 14:16:39

标签: javascript node.js proxy gruntjs grunt-connect-proxy

我正在使用此库将api-request从grunt(端口9000)转发到我的api at node(端口3012)。 https://github.com/drewzboto/grunt-connect-proxy

当服务器的响应是json时,它可以工作。但是当它是图像时它不起作用。

我尝试用apache创建一个代理,并且它有效。所以我的代理人在grunt中一定有问题。

这是来自apache的chrome响应: enter image description here

这是来自grunt服务器的chrome中的repsonse enter image description here

响应标签为空

这些是我正在使用的相关软件包:

"grunt": "^0.4.1",
"grunt-connect-proxy": "^0.2.0",

这是我的gruntfile.js中的代理

  proxies: [
    {
      context: '/api_paros',
      host: 'localhost',
      port: 3012,
      https: false
    }
  ],

livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ],
          middleware: function (connect, options) {
            if (!Array.isArray(options.base)) {
              options.base = [options.base];
            }

            // Setup the proxy
            var middlewares = [require('grunt-connect-proxy/lib/utils').proxyRequest];

            middlewares.push(connect.static('.tmp'));

            middlewares.push(connect().use(
              '/bower_components',
              connect.static('./bower_components')
            ));
            middlewares.push(connect.static(appConfig.app));

            // Serve static files.
            options.base.forEach(function (base) {
              middlewares.push(connect.static(base));
            });

            // Make directory browse-able.
            var directory = options.directory || options.base[options.base.length - 1];
            middlewares.push(connect.directory(directory));

            return middlewares;
          }
        }
      },

有什么想法吗?

0 个答案:

没有答案
相关问题