我想将子目录作为静态文件index.html提供服务。/media索引文件应同时提供 at/index.html和/URL。
我有
web_server.use("/media", express.static(__dirname + '/media'));
web_server.use("/", express.static(__dirname));
但第二行显然服务于整个__dirname,包括其中的所有文件(不仅仅是index.htmland media),这是我不想要的。
我也试过
web_server.use("/", express.static(__dirname + '/index.html'));
但是访问基本 URL/然后会导致对web_server/index.html/index.html(双index.html组件)的请求,这当然会失败。
有任何想法吗?
顺便说一句,我在 Express 中完全找不到关于这个主题的文档(static()+ 它的参数)......令人沮丧。也欢迎提供文档链接。