Open yankee42 opened 9 years ago
+1 I have the very same issue.
This seems work...
middleware: function(connect, options, middlewares) {
middlewares.unshift(require('grunt-connect-proxy/lib/utils').proxyRequest);
return middlewares;
}
Hi!
So the issue appears to be that grunt-contrib-connect@0.11.0 moved to using connect@3.4.0 which has a different syntax for serving static files. I've just put a bug fix in to grunt-contrib-connect to ask them to make it clearer that the syntax has changed (grunt-contrib-connect#205) however, to be clearer here the fix is to:
At the top of your Gruntfile.js you need to add:
var serveStatic = require('serve-static');
Then wherever connect.static is used you simply replace:
connect.static(...)
with: serveStatic(...)
Or at least that appears to be it!
The example "Adding the middleware - With Livereload" in the README.md breaks when updating grunt-contrib-connect to version 0.11.0 because the
connect
parameter is missing the methodsstatic
anddirectory
. With version 0.10.1 it still works fine. Here is the error:The version history for grunt-contrib-connect says the change in this version was:
update to connect 3.
. I am not familiar with how connect works internally but I guess that the API has changed and the documentation here (README.md) needs to be changed as well.