drewzboto / grunt-connect-proxy

Grunt Connect support for proxying API calls during development
MIT License
424 stars 122 forks source link

Proxy Server Doesn't Actually Start on Port #105

Open thinq4yourself opened 9 years ago

thinq4yourself commented 9 years ago

I have a project that uses grunt-connect during development, and we use a proxy server to route requests to our API during development using grunt-connect-proxy. This setup works fine on everyone's local machines, but when I try to set the project up on a remote Linux server, the proxy fails to fun on a port.

When I run $ grunt serve, grunt states that the proxy is created. When I look at the listening ports, the port that the proxy is configured on (8000) is not present. The connect server is running just fine (port 9000).

When I run the app and try to hit a configured proxy URL, I get a ECONNREFUSED error. This indicates nothing is running at port 8000, and that the proxy that Grunt said is running is not running.

After a long search, nothing coming up, and so I am asking for your help. At this point I am fairly certain that the proxy is finicky with the environment. Your help is much appreciated.

connect: {
            options: {
                port: 9000,
                hostname: '0.0.0.0',
                livereload: 4201
            },
            proxies: [{
                context: ["/xyz"],  // When the url contains this...
                host: '0.0.0.0', // Proxy to this host
                port: 8000,
                https: false,
                changeOrigin: true
            }],
            livereload: {
                options: {
                    open: true,
                    middleware: function (connect, options) {
                        var middlewares =  [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect.static(appConfig.app)
                        ];

                        // from https://github.com/drewzboto/grunt-connect-proxy
                        if (!Array.isArray(options.base)) {
                            options.base = [options.base];
                        }
                        // set up the proxy
                        middlewares.push(require('grunt-connect-proxy/lib/utils').proxyRequest);
                        //serve static files
                        options.base.forEach(function (base) {
                            middlewares.push(connect.static(base));
                        });
                        // make directory browseable
                        var directory = options.directory || options.base[options.base.length - 1];
                        middlewares.push(connect.directory(directory));

                        return middlewares;
                    }
                }
            }, 
...
cholathit commented 8 years ago

I have the same issue. Any guidance is much appreciated.