-
Notifications
You must be signed in to change notification settings - Fork 194
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
Serve multiple directories #192
Comments
If you are using Express you should be able to just install two middlewares, one for each directory you want to serve. It will fall through the first middleware if the file isn't found in that directory, and it will move down the middleware chain.
|
Thanks, but we specifically wanted a light-weight http server and chose not to use express. |
Thanks, but we specifically wanted a light-weight http server and chose not to use express. |
You can do the same trick, roughly, but using stock http, something like: http.createServer((req, res) => {
ecstaticFirstDir(req, res, (err) => {
if (shouldFail(res, err)) {
return fail(res, error);
}
ecstaticSecondDir(req, res);
});
}) There is no way to do this from the CLI, but if you're doing that anyway...have you considered nginx? |
I can try that, though seems trivial for the package to add support for multiple dirs. This has to be purely-node driven based on our use case. |
Adding support for multiple dirs in the middleware itself is probably harder than it sounds, and not a road I want to go down, especially considering more far-reaching work like what #183 entails. Adding this to the cli might be doable...if you can convince me that your use case is common. I tend to tell people to use nginx for general purpose non-development static file hosting, since that project is much more industrial grade, properly benchmarked, has fewer bugs etc. |
I'd like to serve static files in two directories - one with my html, one with some compiled css that gets distributed with an npm package. I don't see a way to do this?
The text was updated successfully, but these errors were encountered: