首页 > 解决方案 > 如何使用 restify 提供静态文件?

问题描述

好的,我见过很多类似的问题,但没有一个能解决我的问题或与实际版本配对。Restify很长一段时间后,我正在尝试使用Express.

import restify from "restify";

const server = restify.createServer();

server.listen(8080, () => {
  console.log("%s listening at %s", server.name, server.url);
});

server.get(
  "/",
  restify.plugins.serveStatic({
    directory: "./public",
    default: "index.html"
  })
);

我期望在访问路线时index.html会显示我的文件。/但是我的服务器正在寻找 css/css/style.css 而不是public/css/style.css.

关于如何解决这个问题的任何提示?此外,任何有关如何更好地理解这一点的材料都将不胜感激。

标签: javascriptnode.jshttprestify

解决方案


推荐阅读