返回

WebSocket 握手期间的 NuxtJS Websocket 错误:缺少“升级”标头

发布时间:2022-07-03 23:51:32 352
# css# nginx# 服务器# 服务器

我对 websocket 也有类似的情况。 WebSocket connection to 'wss://xxxx.zzz/socket.io/?EIO=4&transport=websocket' failed: Error during WebSocket handshake: 'Upgrade' header is missing

该项目基于 NuxtJS 框架。服务器在 express.js 上运行

nginx conf

    location / {
        proxy_pass      http://127.0.0.1:5000;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header    Connection  "Upgrade";
            proxy_set_header    Upgrade     $http_upgrade;
        location ~* ^.+\.(jpeg|jpg|png|webp|gif|bmp|ico|svg|css|js)$ {
            expires     max;
            fastcgi_hide_header "Set-Cookie";
        }
    }

服务器上的进程

const http = require("http").createServer(app);
let io = require("socket.io")(http, {
  cors: { origin: "*" },
});

nuxt.config.js

 io: {
        // module options
        sockets: [{
            name: "home",
            url: "https://xxxx.zzz/",
        },],
    },

我在Stackowerflow中尝试了所有流程,但都没有成功。服务器正在通过SSL运行。

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像