node.js - http POST 上的 net::ERR_SSL_PROTOCOL_ERROR 到 express 服务器

标签 node.js reactjs express ssl

我正在尝试从 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/

相关文章:

node.js - 将查询从链接传递到服务器,第一次加载查询值未定义,重新加载后得到正确的查询

node.js - 如何以只读模式获取Draft js中的链接?

javascript - 如何在 node.js 生成的 html 中显示变量

reactjs - Dispatch 不是函数 useContext/useReducer React hooks

javascript - `axios.post()` 之后更新状态

javascript - 无法在 nodeJS :TypeError: Cannot use 'in' operator to search for 'username' in fs 中对用户进行身份验证

python - 使用谷歌云函数生成 python 脚本

node.js - 在 Node 中使用 ES6 的更多功能(除了已发布的功能之外)(例如 "import/export")

javascript - React - 如何确定组件是否是无状态/功能性的?

javascript - react 多个组件添加项目