简体   繁体   English

http POST 上的 net::ERR_SSL_PROTOCOL_ERROR 到快递服务器

[英]net::ERR_SSL_PROTOCOL_ERROR on http POST to express server

I'm trying to post from a react client to an express server on localhost and I get this error in google chrome.我正在尝试从反应客户端发布到本地主机上的快速服务器,我在谷歌浏览器中收到此错误。

react app: http://localhost:3000 express app: http://localhost:5000反应应用程序: http://localhost:3000快递应用程序: http://localhost:5000

POST https://localhost:5000/upload net::ERR_SSL_PROTOCOL_ERROR

I don't have any SSL https self signed certificate, but do I need to?我没有任何 SSL https 自签名证书,但我需要吗? I have used create-react-app inside a directory within my express application to bootstrap my front-end so I'm unaware if maybe a webpack setting somewhere is trying to handle http as https for this particular operation?我已经在我的 express 应用程序的一个目录中使用 create-react-app 来引导我的前端,所以我不知道某处的 webpack 设置是否试图将 http 处理为 Z5E056C500A1C488BADE550D?

I haven't used any bootstrapping for my express js application and I'll include my server file below for reference.我没有为我的 express js 应用程序使用任何引导程序,我将在下面包含我的服务器文件以供参考。

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})
    } 
})

I know there are a fair few questions on this issue but they weren't relevant or didn't provide me any insight.我知道关于这个问题有很多问题,但它们不相关或没有为我提供任何见解。 I have tried making sure the ports are allowed through my firewall aswell.我已经尝试确保端口也允许通过我的防火墙。 I have also cleared my browser cache.我还清除了我的浏览器缓存。

This has been discussed in multiple posts这已经在多个帖子中讨论过

By default you cannot call localhost request on browsers but you can disable the security默认情况下,您无法在浏览器上调用 localhost 请求,但可以禁用安全性

Check here : Disable same origin policy in Chrome在这里检查: 在 Chrome 中禁用同源策略

我遇到了同样的问题,并将 URL 更改为http://localhost:5000/upload而不是使用 https://localhost:5000/upload。

I also faced the same issue and I changed the URL to http://localhost:5000/path instead of using https://localhost:5000/path我也遇到了同样的问题,我将 URL 更改为http://localhost:5000/path而不是使用 https://localhost:5000/path

It works for me.这个对我有用。

I had the same issue but it was with WAGMI (react hooks for web3 dev) and instead of using "https://localhost:6969" (this was the RPC url for my local node) I used "http://localhost:6969" which worked!我遇到了同样的问题,但它与 WAGMI(web3 开发的反应挂钩)有关,而不是使用“https://localhost:6969”(这是我本地节点的 RPC url)我使用了“http://localhost: 6969" 有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Node.js Express中运行https服务器时出现ERR_SSL_PROTOCOL_ERROR浏览器错误消息 - ERR_SSL_PROTOCOL_ERROR browser error message while running a https server in nodejs express ERR_SSL_PROTOCOL_ERROR 仅适用于某些用户(nodejs,express) - ERR_SSL_PROTOCOL_ERROR only for some users (nodejs, express) NodeJS https服务器使用express返回ERR_SSL_PROTOCOL_ERROR - NodeJS https server returning ERR_SSL_PROTOCOL_ERROR using express socket.io 错误网络::ERR_SSL_PROTOCOL_ERROR - socket.io error net::ERR_SSL_PROTOCOL_ERROR POST https://localhost:5000/stored net::ERR_SSL_PROTOCOL_ERROR - POST https://localhost:5000/stored net::ERR_SSL_PROTOCOL_ERROR 在 axios reactJs 中获取 net::ERR_SSL_PROTOCOL_ERROR - getting net::ERR_SSL_PROTOCOL_ERROR in axios reactJs 向服务器 IP 发出请求时出现 ERR_SSL_PROTOCOL_ERROR - ERR_SSL_PROTOCOL_ERROR when making request to server IP 连接建立错误:尝试建立并连接到Websocket服务器时,抛出net :: ERR_SSL_PROTOCOL_ERROR - Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR is thrown when trying establish and connect to a websocket server Docker ERR_SSL_PROTOCOL_ERROR - Docker ERR_SSL_PROTOCOL_ERROR Nginx 代理到 node.js 服务器 SSL ERR_SSL_PROTOCOL_ERROR - Nginx proxy to node.js server SSL ERR_SSL_PROTOCOL_ERROR
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM