0

I started using gulp for my project. Earlier in the project i used grunt in which i was able to configure Ajax requests using grunt-connect-proxy.

GruntFile.js

connect: {

            options: {
                hostname: 'localhost',
                port: 9001,
                open: true,
                base: ['../'],
                middleware: function (connect) {
                    return [
                        proxySnippet,
                        connect.static('../')

                    ];
                },
                livereload: true
            },

        proxies: [
            {
                context: '/data/fetch',
                host: 'prt-service.test.com',
                port: 8080,
                https: false,
                changeOrigin: true
            },
            {
                context: '/data/report',
                host: 'prt-service.test.com',
                port: 8080,
                https: false,
                changeOrigin: true
            },
            {
                context: '/data/group',
                host: 'prt-service.test.com',
                port: 8080,
                https: false,
                changeOrigin: true
            }
        ],

    },

I tried to do the same using gulp-connect-proxy but not able to acheive the same

GulpFile.js

connect.server({
  root: "../",
  port: 3000,
  livereload: true,
      middleware: function (connect, opt) {
      opt.route = 'prt-service.test.com/data/';
      var proxy = new Proxy(opt);
      return [proxy];
  }
});

what i am doing wrong here. could you please provide me a soltuion

user1153484
  • 197
  • 3
  • 13
  • I think you have missed to define `connect.server({ ... });` inside gulp task `gulp.task('connect', function () { // connect });` [check this](https://www.npmjs.com/package/gulp-connect-proxy) – Vinodhan Oct 28 '15 at 08:44
  • @Vinodhan no. i did defined the task but it works using 'http-proxy-middleware' :) var proxy = proxyMiddleware('/data', {target: 'prt-service.test.com'}); browserSync.init({ server:{ baseDir: "../", port: 3000, middleware: [proxy] } }); – user1153484 Nov 02 '15 at 11:43

0 Answers0