- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 http 服务器,但我不知道它为什么不运行;
index.js 文件:
const express = require("express");
const app = (global.app = express());
const helmet = require("helmet");
const server = require("http").createServer(app);
const io = (global.io = require("socket.io")(server));
const config = require("./config.js");
//Middleware
app.use(helmet());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
require("./socket")(io);
require("./router")(app);
server.listen(config.PORT, () => console.log(`Listen on port ${config.PORT}...`));
路由器文件:
const express = require("express");
const path = require("path");
module.exports = (app) => {
app.use(express.static(path.join(__dirname, "/../public/main")));
app.use("/board/:id", express.static(path.join(__dirname, "/../public/paint")));
app.get("*", (req, res) => {
res.status(404).sendFile(path.join(__dirname, "/../", "/public/404/404.html"));
});
};
Chrome 显示错误:
GET https://10.0.1.55:5000/board/jsdbf/style.css net::ERR_SSL_PROTOCOL_ERROR
GET https://10.0.1.55:5000/socket.io/socket.io.js net::ERR_SSL_PROTOCOL_ERROR
适用于所有 js、css 和 imgs。 index.html 正确加载。
最佳答案
我不是内容安全策略方面的 100% 专家,但我注意到了一些事情。
如Benjamin Lemoine指出,net::ERR_SSL_PROTOCOL_ERROR
使用 Helm 时出现问题 (app.use(helmet())
)。我不认为解决方案是根本不使用 Helm ,因为它为应用程序提供了安全性。
对所有 Helm 进行暴力破解后middlewares (contentSecurityPolicy、dnsPrefetchControl、expectCt、frameguard 等),我发现 contentSecurityPolicy
正在创建错误。 WDN文档说 升级不安全请求 指令指示用户代理将站点的所有不安全 URL(通过 HTTP 提供的 URL)视为已替换为安全 URL(通过 HTTPS 提供的 URL)。
所以为了解决问题并同时使用 Helm ,我改变了这个:
app.use( helmet() );
对此:
app.use( helmet() );
app.use(helmet.contentSecurityPolicy({
directives: {
...defaultDirectives,
},
}));
这样我仍在使用 Helm ,但 CSP 指令并未强制 HTPP 使用 HTTPS。请记住
升级不安全请求 应在生产环境中设置指令。
关于node.js - http服务器中的NodeJS err-ssl-protocol-error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64534727/
在编程方面我是个菜鸟。我正在尝试了解 Node.js 和 MongoDB。 下面是我的代码,它将搜索数据库并按州(例如加利福尼亚州、夏威夷州、佛蒙特州等)和最高温度对其进行排序。 当我运行 app.j
我可能在这里遗漏了一些非常简单的东西: package main import ( "fmt" "strconv" "reflect" ) func main() {
我正在尝试运行 npm install bitgo命令但在终端上出现以下错误, npm ERR! code EMFILE npm ERR! syscall spawn git npm ERR! pat
我问了另一个与错误有关的问题。不确定我是否应该编辑该问题。 无论如何,对于下面的代码: app.use((err, req, res, next) => { res.status(err.stat
我正在使用 Promise,并且代码如下所示: function getStuff() { return fetchStuff().then(stuff => process(stuff)
这个问题已经有答案了: Why is `throw` invalid in an ES6 arrow function? (3 个回答) 已关闭 6 年前。 以下代码可以正常工作: pool.get
当我尝试向 redis 添加模块时,出现错误:(err) ERR 不支持的 CONFIG 参数:module-add 我已经通过以下方式安装了动态 redis :- $mkdir -p ~/repos
当我重新分片redis集群时,我遇到了一个问题。 redis集群信息和问题详情如下: obasa04:/usr/redis-4.0.2/src # redis-trib.rb info 10.239.
有什么理由在nodejs中写next(new Error(err))而不是next(err)吗? 非常感谢! 最佳答案 在没有任何上下文的情况下,我假设err已经是一个对象(通常在节点中),因此没有理
我正在尝试创建一个从 API 获取数据的全栈 Node 和 Vue 应用程序。我遇到了一个问题,我试图同时运行客户端和服务器,但代码遇到错误。如果我错误地构建了这个问题,请耐心等待,因为我对编码还很陌
我要更新 npm 最新版本,但显示此错误消息: G:\>npm i -g npm ERR! code ENOLOCAL npm ERR! Could not install from "" as it
为什么在执行 sudo npm install npm 时会出现这个奇怪的错误?我有时在尝试安装其他模块时也会得到它! 错误: > scrypt@6.0.3 preinstall /home/user
我使用 ctypes 围绕 libbgpdump 编写了一个 python 包装器,但是当 libbgpdump 调用“err()”时它会出现段错误。这是失败的 C 代码: if(count > MA
我想运行这个项目:https://github.com/adonis-china/adonis-adminify 当我运行npm install时,存在错误: > sqlite3@3.1.13 ins
我尝试在我的服务器上运行 npm install 并收到此错误。 > node-cron@2.0.3 postinstall /home/workspace/AgreementCancellation
我正在尝试在我的 Node 项目上创建一个错误处理程序,但我不明白一些事情。 对于抛出的错误,我可以从 2 种不同的方式中捕获: 进程.on() process.on('uncaughtExcepti
当我在我的“npm cache clean”中写入时,出现了这个错误“npm ERR!Windows_NT 6.3.9600 npm ERR!argv” C:\iaAC>npm cache clean
在我的 npm run 构建脚本执行后,我很难深入了解我收到的 npm 错误。终端报错如下: npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! vi
我试图在一个新的项目目录中运行 yo angular,但它在途中的某个地方给了我 ENOENT 错误。是的,我看过 this similar question ,但它的解决方案对我不起作用。 在运行
试图在 Ubuntu 18.04 x64 上运行它。它曾经在一天前正常工作,但它突然停止了。 npm i simple-youtube-api 我曾经能够安装它们但不是任何人,我得到这个: > buf
我是一名优秀的程序员,十分优秀!