Closed zenhunt closed 10 years ago
+1 Downgrading grunt-contrib-connect to 0.7.1 is a workaround.
As of v0.1.11 this plugin work with fine with grunt-contrib-connect 0.8.0.
Closing since v0.1.11 is released. Please re-open if this is still an issue.
i just encountered the same issue with grunt-contrib-connect
/0.8.0
and grunt-connect-proxy
/0.1.11
.
downgrading to grunt-contrib-connect
/0.7.1
made the issue go away...
let me know if i can provide any more information to assist troubleshooting...
regards, tony.
so... the problem didn't actually go away when using grunt-contrib-connect
/0.7.1
, this warning went away:
Warning: Arguments to path.resolve must be strings Use --force to continue.
but i continued to have other issues at runtime.
it actually turned out to be operator error with this grunt config:
connect: {
server: {
options: {
port: 9000,
hostname: 'localhost',
base: 'build',
middleware: function (connect, options) {
var proxy = require('grunt-connect-proxy/lib/utils').proxyRequest;
console.log("middleware: options=%o", options);
return [
// Include the proxy first
proxy,
// Serve static files.
connect.static(options.base)
// Make empty directories browsable.
//connect.directory(options.base)
];
},
debug: true
},
proxies: [
{
context: '/api',
host: 'localhost',
port: 3000
}
]
}
},
when i dumped the options
arg via console.log
it showed that options.base
was actually an array by the time it got passed into the function specified as the middleware
field.
so something like what the author of this post shown below would be the real solution to the issue:
middleware: function(connect, options) {
var middlewares = [];
var directory = options.directory ||
options.base[options.base.length - 1];
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
options.base.forEach(function(base) {
// Serve static files.
middlewares.push(connect.static(base));
});
// Make directory browse-able.
middlewares.push(connect.directory(directory));
return middlewares;
}
regards, tony.
Perfect life saver! Thanks Tony.
Tony! n1. Thank you.
Whee! Is still broken btw. Will try the workaround.
This plugin is broken in usage with grunt connect 0.8.0, updating to this version will result in the following error:
Running "connect:devproxy" (connect) task Verifying property connect.devproxy exists in config...OK File: [no files] Options: protocol="http", port=9997, hostname="closedhost", base="tmp", directory=null, keepalive=false, debug=false, livereload, open=false, useAvailablePort=false,onCreateServer=null, middleware=undefined Warning: Arguments to path.resolve must be strings Use --force to continue.
Please fix. :)
Best Regards,
@zenhunt