schickling / gulp-webserver

Streaming gulp plugin to run a local webserver with LiveReload
https://www.npmjs.org/package/gulp-webserver
MIT License
355 stars 84 forks source link

TypeError: res.send is not a function #120

Open felikf opened 7 years ago

felikf commented 7 years ago

I would like to serve alternative index file in some circumstaces: ("gulp-webserver": "0.9.1")

 middleware: function(req, res, next) {
                if ('/' === req.url) {
                    fs.readFile('index_orig.html', 'utf8', function(err, data) {
                        if (err) throw err;
                        res.send(data);
                    });
                }
            }

But I am getting this error:

C:\Users\felix\project\run-dev.js:36
                        res.send(data);
                            ^

TypeError: res.send is not a function
    at C:\Users\felix\project\run-dev.js:36:29
    at tryToString (fs.js:456:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)
factoidforrest commented 6 years ago

I'm doing the same thing and I'm getting the same issue!

rehman22 commented 6 years ago

i have also issue