これは、google.com への単なるプロキシである最小限のデモを作成する方法です。
走る:
npm install grunt-connect-proxy --save-dev
npm install grunt-contrib-connect --save-dev
次の Gruntfile.js を作成します。
module.exports = function (grunt) {
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
grunt.initConfig({
connect: {
server: {
options: {
hostname: 'localhost',
keepalive: true,
open: true,
middleware: function (connect, options) {
return [proxySnippet];
}
},
proxies: [{
context: '/',
host: 'google.com',
port: 80
}]
}
}
});
grunt.loadNpmTasks('grunt-connect-proxy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', [
'configureProxies:server',
'connect:server']);
};
今すぐ実行してgrunt
ください。