shakyShane / browser-sync-spa

Better Single Page App support for BrowserSync
29 stars 15 forks source link

Using browser-sync-spa with middleware will occurr error #1

Closed indigofeather closed 9 years ago

indigofeather commented 9 years ago

The following is the code:

var options;

options = {
  server: {
    baseDir: './src',
    middleware: function(req, res, next) {
      // do something...
      next();
    }
  }
};

browserSync.use(spa());
browserSync(options);

with middleware:

Caught exception: TypeError: Object function (req, res, next) { has no method 'push'

without middleware:

[BS] Local URL: http://localhost:3000
[BS] External URL: http://192.168.62.128:3000
[BS] Serving files from: ./src
[BS] [BrowserSync SPA] Running...

If I did something wrong, please tell me.

shakyShane commented 9 years ago

It's a bug - before I get chance to fix it though, you can get it working by providing your middleware in an array.

middleware: [function(req, res, next) {
    // do something...
    next();
}]

Hope that helps :)

indigofeather commented 9 years ago

It works! Thanks a lot :)