我正在尝试从 react 客户端发布到本地主机上的快速服务器,我在谷歌浏览器中收到此错误。
react 应用:http://localhost:3000
express 应用:http://localhost:5000
POST https://localhost:5000/upload net::ERR_SSL_PROTOCOL_ERROR
我没有任何 SSL https 自签名证书,但我需要吗?我已经在我的 express 应用程序的一个目录中使用 create-react-app 来引导我的前端,所以我不知道某处的 webpack 设置是否试图将 http 作为 https 处理这个特定操作?
我没有为我的 express js 应用程序使用任何 Bootstrap ,我将在下面包含我的服务器文件以供引用。
const express = require ('express')
const bodyParser = require ('body-parser')
const port = 5000
var app = express()
var cors = require("cors");
app.use(cors())
app.use(bodyParser())
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
app.post('/upload', (req,res)=>{
if (req.files === null ){
return res.status(400).json({message: 'no image uploaded please try again'})
}else{
const file = req.files.file
let body = req.body
res.json({body})
}
})
我知道关于这个问题有很多问题,但它们不相关或没有为我提供任何见解。我已经尝试确保端口也允许通过我的防火墙。我还清除了我的浏览器缓存。
最佳答案
我遇到了同样的问题,并将 URL 更改为 http://localhost:5000/upload
而不是使用 https://localhost:5000/upload。
关于node.js - http POST 上的 net::ERR_SSL_PROTOCOL_ERROR 到 express 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60548707/