-
Notifications
You must be signed in to change notification settings - Fork 0
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
Doesn't work with Koa v1.2.0 #4
Comments
Here is my solution: const originalServeStatic = serveStatic(...);
app.use(function* (){
yield new Promise((resolve, reject) => {
// hacked statusCode
if (this.status === 404) this.status = 200;
// unnecessary response by koa
this.respond = false;
// 404, serve-static forward non-404 errors
// force throw error
originalServeStatic(this.req, this.res, reject);
})
}); |
Working for anyone? |
Which is version of serve-static in your project? |
@fundon - This is my working code using Express' serve-static. However, the module won't be able to use // app.js
var serveStatic = require('serve-static');
var originalServeStatic = serveStatic(...);
app.use(function* (){
try {
yield new Promise((resolve, reject) => {
this.status = 200;
originalServeStatic(this.req, this.res, reject);
});
} catch (error) {
this.status = 404;
}
}); |
If want to work with koa v1, should install serve-static 0.x( < 1.0). |
The text was updated successfully, but these errors were encountered: