gpt4 book ai didi

node.js - RESTIFY 不提供子目录中的静态文件

转载 作者:太空宇宙 更新时间:2023-11-03 22:17:30 26 4
gpt4 key购买 nike

我正在尝试使用以下代码通过 Restify 提供静态文件。

app.get(/.*/, restify.serveStatic({
directory: __dirname + '/public',
default: 'index.html'
}));

调用 GET/或 GET/index.html 按预期工作。调用 public 子目录中的任何文件都不起作用。例如,调用 GET/css/style.css 会导致 404。文件存在但未提供服务。

有什么想法吗?

最佳答案

尝试这样,对我来说效果很好:

app.get(/.*/, restify.serveStatic({
directory: 'public',
default: 'index.html'
}));

关于node.js - RESTIFY 不提供子目录中的静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21266668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com