gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 146 forks source link

Livereload breaks the middleware #185

Closed lnfnunes closed 6 years ago

lnfnunes commented 9 years ago

I'm using compression package for gzip my responses. It works fine if livereload options is "false". When I turn it on the middleware stops working and the browser has blank responses from server (no page). Bellow is my middleware configuration:

server: {
  options: {
    port: 8000,
    livereload: false,
    keepalive: false,
    middleware : function(connect, options, middlewares) {
      // Some bug if ivereload is enabled !!!
      if (!options.livereload) {
        middlewares.unshift(compression());
      }
      return middlewares;
    }
}
amir-rahnama commented 8 years ago

I can't reproduce this really. I tried putting it on and off and in both cases, middleware.unshift is not working.

chhaymenghong commented 6 years ago

@lnfnunes try the following:

If you are not using a proxy, you can get rid of the "grunt-middleware-proxy" middleware.

lnfnunes commented 6 years ago

Thanks in advance! Unfornutly, nowadays I don't have this scenario anymore so I can't confirm if this works or not. Thanks for you reply @chhaymenghong!