Websocket always returns 403 in nodejs

Viewed 11

I have a problem when connecting to a websocket server, it was working great before it broke somehow but now the server always returns a "403 Forbidden" when sending a websocket open request.

I've tried several websocket clients and maybe thought that that would fix it. I also copied the headers from the browser but none worked (including trying origin and host headers/sec-websocket headers). But here comes the funny part: When i try it in a browser console from any site and origin it just works and opens fine.

I tried the following headers and websocket modules:

ws, websocket

    "Host": "site",
    "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0",
    "Accept": "*/*",
    "Accept-Language": "en-US,en;q=0.5",
    "Accept-Encoding": "gzip, deflate, br",
    "Sec-WebSocket-Version": 13,
    "Origin": "site",
    "Sec-WebSocket-Extensions": "permessage-deflate",
    "Sec-WebSocket-Key": "key",
    "DNT": 1,
    "Connection": "keep-alive, Upgrade",
    "Cookie": "cookies",
    "Sec-Fetch-Dest": "websocket",
    "Sec-Fetch-Mode": "websocket",
    "Sec-Fetch-Site": "same-origin",
    "Pragma": "no-cache",
    "Cache-Control": "no-cache",
    "Upgrade": "websocket"

What am i doing wrong.

0 Answers
Related