javascript - Node.js/Express 静态资源连接被拒绝

标签 javascript node.js express

我刚刚将 Express 应用程序部署到生产服务器,并且不再为我提供静态 Assets 。

我的 Assets 位于 /public 中,我这样调用静态中间件:

// config.root => /var/www
app.use(express.static(config.root + '/public'));

当我启动网站时,样式表未通过,我看到:

GET http://--- redacted ---/scripts/main.js net::ERR_CONNECTION_REFUSED

如果我打开样式表 URL,我可以看到它没有问题。

我在这里缺少什么?

最佳答案

我的中间件函数之一存在错误(未定义函数)。检查你的日志, friend 们!

关于javascript - Node.js/Express 静态资源连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30197074/

相关文章:

javascript - 箭头函数内的 "Uncaught TypeError: this._isDateType is not a function"

javascript - 类似 treeview 的 jquery 插件

node.js - 我的命名空间未定义。 typescript

templates - NodeJS + Express + Handlebars - 找不到 View "index.html"

javascript - 如何通过假定默认内容类型来解析 Express/NodeJs 中缺少内容类型的 HTTP 请求?

javascript - Node.js 服务器到服务器加密

javascript - 为什么我的 Service Worker 会看到 "Error - Only secure origins are allowed"?

javascript - Babili 缩小但不转译

node.js - 在 Node.js 中运行异步进程

node.js - 获取客户端 IP 地址的最佳方法是 req.ip 还是 req.connection.remoteAddress?