-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expressStaticGzip fail to handle single file #13
Comments
Hi, as i wanted to restructure the code of expressStaticGzip for a while now and make it easier to test, i will have a look at your issue while doing so. At the moment I can not guarantee any timeframe when this will be done, as my main focus is on adding tests to ensure no future changes will break the module. Regards, |
Ok, it's not very urgent, thanks and good luck with your refactoring ! |
oops, maybe the issue can keep open... |
There is no point to serve service-worker.js with expressStaticGzip cos you can't gzip it anyway, at least with Webpack's CompressionPlugin. Does anybody knows the better way to serve * route with 'express-static-gzip' than I pointed below?
Hope it will be possible to have options to serve single file or array of files, not only the directory. Thank you for a great plugin! |
I think you can reduce your last two middleware registrations to just one like this: app.use(expressStaticGzip('client/build')) This should handle all requests, that would not have been handled before. But you might want to have some other request handler at this position, to serve "404" errors. I tried adding the single file functionality a while ago, but it took me quite some time, and i did not figure out a simple solution at that time. As this was not one of my own use cases, i stopped implementing. Any PR providing such functionality would be welcome :) |
@FranckFreiburger you could use
|
Like serve-static, express-static-gzip should also be able to serve a single file.
eg:
expressApp.use('/service-worker.js', expressStaticGzip('service-worker.js'));
Currently, the error is:
The text was updated successfully, but these errors were encountered: