gulp-webserver icon indicating copy to clipboard operation
gulp-webserver copied to clipboard

fallback + script 404's cause weird errors

Open ghost opened this issue 10 years ago • 3 comments

The fallback should be refactored so 404's caused by missing scripts to do not get redirected to index.html (the fallback). Because this causes weird console messages and hides the fact there is a 404.

ghost avatar Jul 17 '15 21:07 ghost

@robertbaker Did you find a work around for this?

sagivf avatar Aug 18 '15 14:08 sagivf

No.

On Tue, Aug 18, 2015, 7:59 AM Sagiv Frankel [email protected] wrote:

@robertbaker https://github.com/robertbaker Did you find a work around for this?

— Reply to this email directly or view it on GitHub https://github.com/schickling/gulp-webserver/issues/88#issuecomment-132240330 .

ghost avatar Aug 18 '15 15:08 ghost

Not the best solution, but you can add middleware to pass through only the files you want:

  • Just add the middleware property:
  return function(req, res, next) {
    if (req.url.indexOf('/app/assets') === 0  || req.url.indexOf('/static') === 0) {
      return next();
    }
    res.statusCode = 404;
    res.setHeader("Content-Type", "text/html");
    res.write("no such static resource");
    return res.end();
  }

sagivf avatar Aug 18 '15 20:08 sagivf