1.0.4 • Published 6 years ago

connect-parse-proxy v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

适用于 grunt-contrib-connect 插件,用于处理反向代理

Example

grunt.initConfig({
    connect: {
        server: {
            options: {
                middleware: function(connect, options, middlewares) {
                    middlewares.unshift(connectProxy([
                        // from /a/b to http://example.com/c/d
                        {
                            location: '/a/b',
                            pass: 'http://example.com/c/d',
                            type: 'text/html; charset=utf-8'
                        },
                        // from /a.1234.js to /a.js
                        {
                            location: /\.\d+\.(js|css)$/,
                            pass: function(req) {
                                var pathName = req._parsedUrl.pathname;
                                return pathName.replace(this.location, '.$1');
                            }
                        }
                    ]));
                    return middlewares;
                }
            }
        }
    }
});

参数说明

  • location String|RegExp 匹配要访问的url
  • pass String|Function 实际访问的url,可以为本地的另一个地址
  • type String 如果pass地址为其他域名的url,则会根据type设置返回头的 Content-Type, 默认值为'text/html; charset=utf-8'
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.2

9 years ago

0.0.1

9 years ago