[{"data":1,"prerenderedAt":1250},["ShallowReactive",2],{"navigation":3,"-guide-proxy":78,"-guide-proxy-surround":1247},[4,41],{"title":5,"path":6,"stem":7,"children":8,"icon":10},"Guide","\u002Fguide","1.guide\u002F1.index",[9,11,16,21,26,31,36],{"title":5,"path":6,"stem":7,"icon":10},"ph:book-open-duotone",{"title":12,"path":13,"stem":14,"icon":15},"Hooks","\u002Fguide\u002Fhooks","1.guide\u002F2.hooks","material-symbols-light:data-object",{"title":17,"path":18,"stem":19,"icon":20},"Peer","\u002Fguide\u002Fpeer","1.guide\u002F3.peer","mynaui:api",{"title":22,"path":23,"stem":24,"icon":25},"Message","\u002Fguide\u002Fmessage","1.guide\u002F4.message","solar:letter-line-duotone",{"title":27,"path":28,"stem":29,"icon":30},"Pub \u002F Sub","\u002Fguide\u002Fpubsub","1.guide\u002F5.pubsub","simple-icons:googlepubsub",{"title":32,"path":33,"stem":34,"icon":35},"Resolver API","\u002Fguide\u002Fresolver","1.guide\u002F6.resolver","tabler:route",{"title":37,"path":38,"stem":39,"icon":40},"WebSocket Proxy","\u002Fguide\u002Fproxy","1.guide\u002F7.proxy","tabler:arrows-exchange",{"title":42,"path":43,"stem":44,"children":45,"icon":47},"Adapters","\u002Fadapters","2.adapters\u002F1.index",[46,48,53,58,63,68,73],{"title":42,"path":43,"stem":44,"icon":47},"emojione-monotone:electric-plug",{"title":49,"path":50,"stem":51,"icon":52},"Bun","\u002Fadapters\u002Fbun","2.adapters\u002Fbun","simple-icons:bun",{"title":54,"path":55,"stem":56,"icon":57},"Bunny","\u002Fadapters\u002Fbunny","2.adapters\u002Fbunny","mdi:rabbit",{"title":59,"path":60,"stem":61,"icon":62},"Cloudflare","\u002Fadapters\u002Fcloudflare","2.adapters\u002Fcloudflare","devicon-plain:cloudflareworkers",{"title":64,"path":65,"stem":66,"icon":67},"Deno","\u002Fadapters\u002Fdeno","2.adapters\u002Fdeno","teenyicons:deno-solid",{"title":69,"path":70,"stem":71,"icon":72},"Node.js","\u002Fadapters\u002Fnode","2.adapters\u002Fnode","akar-icons:node-fill",{"title":74,"path":75,"stem":76,"icon":77},"SSE","\u002Fadapters\u002Fsse","2.adapters\u002Fsse","clarity:two-way-arrows-line",{"id":79,"title":37,"body":80,"description":1241,"extension":1242,"meta":1243,"navigation":1244,"path":38,"seo":1245,"stem":39,"__hash__":1246},"content\u002F1.guide\u002F7.proxy.md",{"type":81,"value":82,"toc":1228,"icon":40},"minimark",[83,87,115,120,130,235,238,244,262,266,274,467,493,497,505,620,641,645,652,687,696,700,706,785,790,808,880,884,900,1028,1066,1070,1076,1086,1202,1224],[84,85,86],"p",{},"crossws ships a small helper that returns a set of ready-made hooks which proxy every peer to an upstream WebSocket server. Use it to put crossws in front of an existing backend, split traffic across services, or bridge protocols between runtimes.",[88,89,90],"note",{},[84,91,92,93,103,104,110,111,114],{},"\nThe proxy uses the global ",[94,95,99],"a",{"href":96,"rel":97},"https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FAPI\u002FWebSocket",[98],"nofollow",[100,101,102],"code",{},"WebSocket"," constructor to dial the upstream, which is available on Node.js ≥ 22, Bun, Deno, Cloudflare Workers, and browsers. On older Node versions, pass a custom constructor via the ",[94,105,107,109],{"href":106},"#custom-websocket-constructor",[100,108,102],{}," option"," or install a polyfill on ",[100,112,113],{},"globalThis",".",[116,117,119],"h2",{"id":118},"usage","Usage",[84,121,122,125,126,129],{},[100,123,124],{},"createWebSocketProxy()"," returns a ",[100,127,128],{},"Partial\u003CHooks>"," object that you can pass straight to any crossws adapter.",[131,132,137],"pre",{"className":133,"code":134,"language":135,"meta":136,"style":136},"language-ts shiki shiki-themes github-light github-dark github-dark","\u002F\u002F https:\u002F\u002Fcrossws.h3.dev\u002Fadapters\nimport crossws from \"crossws\u002Fadapters\u002F\u003Cadapter>\";\nimport { createWebSocketProxy } from \"crossws\";\n\nconst websocket = crossws({\n  hooks: createWebSocketProxy(\"wss:\u002F\u002Fecho.websocket.org\"),\n});\n","ts","",[100,138,139,148,169,184,191,211,229],{"__ignoreMap":136},[140,141,144],"span",{"class":142,"line":143},"line",1,[140,145,147],{"class":146},"sCsY4","\u002F\u002F https:\u002F\u002Fcrossws.h3.dev\u002Fadapters\n",[140,149,151,155,159,162,166],{"class":142,"line":150},2,[140,152,154],{"class":153},"so5gQ","import",[140,156,158],{"class":157},"slsVL"," crossws ",[140,160,161],{"class":153},"from",[140,163,165],{"class":164},"sfrk1"," \"crossws\u002Fadapters\u002F\u003Cadapter>\"",[140,167,168],{"class":157},";\n",[140,170,172,174,177,179,182],{"class":142,"line":171},3,[140,173,154],{"class":153},[140,175,176],{"class":157}," { createWebSocketProxy } ",[140,178,161],{"class":153},[140,180,181],{"class":164}," \"crossws\"",[140,183,168],{"class":157},[140,185,187],{"class":142,"line":186},4,[140,188,190],{"emptyLinePlaceholder":189},true,"\n",[140,192,194,197,201,204,208],{"class":142,"line":193},5,[140,195,196],{"class":153},"const",[140,198,200],{"class":199},"suiK_"," websocket",[140,202,203],{"class":153}," =",[140,205,207],{"class":206},"shcOC"," crossws",[140,209,210],{"class":157},"({\n",[140,212,214,217,220,223,226],{"class":142,"line":213},6,[140,215,216],{"class":157},"  hooks: ",[140,218,219],{"class":206},"createWebSocketProxy",[140,221,222],{"class":157},"(",[140,224,225],{"class":164},"\"wss:\u002F\u002Fecho.websocket.org\"",[140,227,228],{"class":157},"),\n",[140,230,232],{"class":142,"line":231},7,[140,233,234],{"class":157},"});\n",[84,236,237],{},"Every incoming peer opens a matching upstream connection. Text and binary messages are forwarded in both directions, and close\u002Ferror events are propagated to the client.",[239,240,241],"tip",{},[84,242,243],{},"\nMessages sent by the client before the upstream connection is ready are buffered and flushed as soon as the upstream is open.",[245,246,247],"caution",{},[84,248,249,253,254,261],{},[250,251,252],"strong",{},"The default proxy is an open relay."," It accepts every incoming connection and forwards it to the configured upstream without any authorization check. Always combine it with an ",[94,255,257,260],{"href":256},"#authentication",[100,258,259],{},"upgrade"," hook"," when the upstream is not itself publicly accessible — otherwise anyone who can reach the proxy can reach the upstream.",[116,263,265],{"id":264},"authentication","Authentication",[84,267,268,270,271,273],{},[100,269,124],{}," returns a plain hooks object, so you can spread it and override individual hooks. Authenticate the upgrade request before proxying by wrapping the proxy's ",[100,272,259],{}," hook:",[131,275,277],{"className":133,"code":276,"language":135,"meta":136,"style":136},"import { createWebSocketProxy } from \"crossws\";\n\nconst proxyHooks = createWebSocketProxy(\"wss:\u002F\u002Fbackend.example.com\");\n\nconst hooks = {\n  ...proxyHooks,\n  async upgrade(req) {\n    const token = req.headers.get(\"authorization\");\n    if (!(await isValidToken(token))) {\n      return new Response(\"Unauthorized\", { status: 401 });\n    }\n    \u002F\u002F Delegate to the proxy's own `upgrade` so subprotocol echoing still works.\n    return proxyHooks.upgrade?.(req);\n  },\n};\n",[100,278,279,291,295,315,319,331,339,356,380,403,429,435,441,455,461],{"__ignoreMap":136},[140,280,281,283,285,287,289],{"class":142,"line":143},[140,282,154],{"class":153},[140,284,176],{"class":157},[140,286,161],{"class":153},[140,288,181],{"class":164},[140,290,168],{"class":157},[140,292,293],{"class":142,"line":150},[140,294,190],{"emptyLinePlaceholder":189},[140,296,297,299,302,304,307,309,312],{"class":142,"line":171},[140,298,196],{"class":153},[140,300,301],{"class":199}," proxyHooks",[140,303,203],{"class":153},[140,305,306],{"class":206}," createWebSocketProxy",[140,308,222],{"class":157},[140,310,311],{"class":164},"\"wss:\u002F\u002Fbackend.example.com\"",[140,313,314],{"class":157},");\n",[140,316,317],{"class":142,"line":186},[140,318,190],{"emptyLinePlaceholder":189},[140,320,321,323,326,328],{"class":142,"line":193},[140,322,196],{"class":153},[140,324,325],{"class":199}," hooks",[140,327,203],{"class":153},[140,329,330],{"class":157}," {\n",[140,332,333,336],{"class":142,"line":213},[140,334,335],{"class":153},"  ...",[140,337,338],{"class":157},"proxyHooks,\n",[140,340,341,344,347,349,353],{"class":142,"line":231},[140,342,343],{"class":153},"  async",[140,345,346],{"class":206}," upgrade",[140,348,222],{"class":157},[140,350,352],{"class":351},"sQHwn","req",[140,354,355],{"class":157},") {\n",[140,357,359,362,365,367,370,373,375,378],{"class":142,"line":358},8,[140,360,361],{"class":153},"    const",[140,363,364],{"class":199}," token",[140,366,203],{"class":153},[140,368,369],{"class":157}," req.headers.",[140,371,372],{"class":206},"get",[140,374,222],{"class":157},[140,376,377],{"class":164},"\"authorization\"",[140,379,314],{"class":157},[140,381,383,386,389,392,394,397,400],{"class":142,"line":382},9,[140,384,385],{"class":153},"    if",[140,387,388],{"class":157}," (",[140,390,391],{"class":153},"!",[140,393,222],{"class":157},[140,395,396],{"class":153},"await",[140,398,399],{"class":206}," isValidToken",[140,401,402],{"class":157},"(token))) {\n",[140,404,406,409,412,415,417,420,423,426],{"class":142,"line":405},10,[140,407,408],{"class":153},"      return",[140,410,411],{"class":153}," new",[140,413,414],{"class":206}," Response",[140,416,222],{"class":157},[140,418,419],{"class":164},"\"Unauthorized\"",[140,421,422],{"class":157},", { status: ",[140,424,425],{"class":199},"401",[140,427,428],{"class":157}," });\n",[140,430,432],{"class":142,"line":431},11,[140,433,434],{"class":157},"    }\n",[140,436,438],{"class":142,"line":437},12,[140,439,440],{"class":146},"    \u002F\u002F Delegate to the proxy's own `upgrade` so subprotocol echoing still works.\n",[140,442,444,447,450,452],{"class":142,"line":443},13,[140,445,446],{"class":153},"    return",[140,448,449],{"class":157}," proxyHooks.",[140,451,259],{"class":206},[140,453,454],{"class":157},"?.(req);\n",[140,456,458],{"class":142,"line":457},14,[140,459,460],{"class":157},"  },\n",[140,462,464],{"class":142,"line":463},15,[140,465,466],{"class":157},"};\n",[88,468,469],{},[84,470,471,472,474,475,478,479,482,483,485,486,492],{},"\nThe WHATWG ",[100,473,102],{}," constructor cannot forward cookies, ",[100,476,477],{},"Authorization",", or ",[100,480,481],{},"Origin"," to the upstream, so upstream identity checks relying on those headers will silently fail. Authenticate at the proxy, or pass a custom ",[100,484,102],{}," client and use the ",[94,487,489,109],{"href":488},"#forwarding-headers",[100,490,491],{},"headers"," to propagate identity.",[116,494,496],{"id":495},"dynamic-target","Dynamic target",[84,498,499,500,504],{},"Pass a function to resolve the upstream URL from the incoming ",[94,501,502],{"href":18},[100,503,17],{}," — useful for routing based on request URL, headers, or authenticated context.",[131,506,508],{"className":133,"code":507,"language":135,"meta":136,"style":136},"import { createWebSocketProxy } from \"crossws\";\n\nconst hooks = createWebSocketProxy({\n  target: (peer) => {\n    const { pathname } = new URL(peer.request.url);\n    return pathname.startsWith(\"\u002Fadmin\") ? \"wss:\u002F\u002Fadmin.internal\u002Fws\" : \"wss:\u002F\u002Fpublic.internal\u002Fws\";\n  },\n});\n",[100,509,510,522,526,538,557,581,612,616],{"__ignoreMap":136},[140,511,512,514,516,518,520],{"class":142,"line":143},[140,513,154],{"class":153},[140,515,176],{"class":157},[140,517,161],{"class":153},[140,519,181],{"class":164},[140,521,168],{"class":157},[140,523,524],{"class":142,"line":150},[140,525,190],{"emptyLinePlaceholder":189},[140,527,528,530,532,534,536],{"class":142,"line":171},[140,529,196],{"class":153},[140,531,325],{"class":199},[140,533,203],{"class":153},[140,535,306],{"class":206},[140,537,210],{"class":157},[140,539,540,543,546,549,552,555],{"class":142,"line":186},[140,541,542],{"class":206},"  target",[140,544,545],{"class":157},": (",[140,547,548],{"class":351},"peer",[140,550,551],{"class":157},") ",[140,553,554],{"class":153},"=>",[140,556,330],{"class":157},[140,558,559,561,564,567,570,573,575,578],{"class":142,"line":193},[140,560,361],{"class":153},[140,562,563],{"class":157}," { ",[140,565,566],{"class":199},"pathname",[140,568,569],{"class":157}," } ",[140,571,572],{"class":153},"=",[140,574,411],{"class":153},[140,576,577],{"class":206}," URL",[140,579,580],{"class":157},"(peer.request.url);\n",[140,582,583,585,588,591,593,596,598,601,604,607,610],{"class":142,"line":213},[140,584,446],{"class":153},[140,586,587],{"class":157}," pathname.",[140,589,590],{"class":206},"startsWith",[140,592,222],{"class":157},[140,594,595],{"class":164},"\"\u002Fadmin\"",[140,597,551],{"class":157},[140,599,600],{"class":153},"?",[140,602,603],{"class":164}," \"wss:\u002F\u002Fadmin.internal\u002Fws\"",[140,605,606],{"class":153}," :",[140,608,609],{"class":164}," \"wss:\u002F\u002Fpublic.internal\u002Fws\"",[140,611,168],{"class":157},[140,613,614],{"class":142,"line":231},[140,615,460],{"class":157},[140,617,618],{"class":142,"line":358},[140,619,234],{"class":157},[621,622,623],"warning",{},[84,624,625,628,629,632,633,636,637,640],{},[250,626,627],{},"SSRF risk."," A dynamic ",[100,630,631],{},"target"," resolver is a trust boundary. Never interpolate untrusted input (query strings, headers, path segments a client controls) directly into the returned URL — a naive resolver turns the proxy into an SSRF primitive that can dial ",[100,634,635],{},"ws:\u002F\u002F127.0.0.1",", ",[100,638,639],{},"ws:\u002F\u002F169.254.169.254",", or any reachable internal service. Always resolve against a hard-coded allowlist of hosts you control.",[116,642,644],{"id":643},"subprotocol-negotiation","Subprotocol negotiation",[84,646,647,648,651],{},"By default, the proxy forwards the client's ",[100,649,650],{},"sec-websocket-protocol"," header to the upstream and echoes the first requested subprotocol back in the upgrade response so the client handshake succeeds. Disable this if you want to negotiate subprotocols yourself:",[131,653,655],{"className":133,"code":654,"language":135,"meta":136,"style":136},"createWebSocketProxy({\n  target: \"wss:\u002F\u002Fbackend.example.com\",\n  forwardProtocol: false,\n});\n",[100,656,657,663,673,683],{"__ignoreMap":136},[140,658,659,661],{"class":142,"line":143},[140,660,219],{"class":206},[140,662,210],{"class":157},[140,664,665,668,670],{"class":142,"line":150},[140,666,667],{"class":157},"  target: ",[140,669,311],{"class":164},[140,671,672],{"class":157},",\n",[140,674,675,678,681],{"class":142,"line":171},[140,676,677],{"class":157},"  forwardProtocol: ",[140,679,680],{"class":199},"false",[140,682,672],{"class":157},[140,684,685],{"class":142,"line":186},[140,686,234],{"class":157},[621,688,689],{},[84,690,691,692,695],{},"\nThe proxy commits to a subprotocol in the upgrade response before the upstream connection is established. If the upstream ultimately picks a different subprotocol (or rejects), the client will still see the one the proxy promised. Only keep ",[100,693,694],{},"forwardProtocol"," enabled when the upstream is known to accept the same subprotocols the client negotiates.",[116,697,699],{"id":698},"custom-websocket-constructor","Custom WebSocket constructor",[84,701,702,703,705],{},"Pass a ",[100,704,102],{}," constructor via options to override the global — useful on Node.js \u003C 22, to plug in a different client implementation, or to stub the upstream in tests.",[131,707,709],{"className":133,"code":708,"language":135,"meta":136,"style":136},"import { WebSocket } from \"ws\";\nimport { createWebSocketProxy } from \"crossws\";\n\nconst hooks = createWebSocketProxy({\n  target: \"wss:\u002F\u002Fbackend.example.com\",\n  WebSocket: WebSocket as unknown as typeof globalThis.WebSocket,\n});\n",[100,710,711,725,737,741,753,761,781],{"__ignoreMap":136},[140,712,713,715,718,720,723],{"class":142,"line":143},[140,714,154],{"class":153},[140,716,717],{"class":157}," { WebSocket } ",[140,719,161],{"class":153},[140,721,722],{"class":164}," \"ws\"",[140,724,168],{"class":157},[140,726,727,729,731,733,735],{"class":142,"line":150},[140,728,154],{"class":153},[140,730,176],{"class":157},[140,732,161],{"class":153},[140,734,181],{"class":164},[140,736,168],{"class":157},[140,738,739],{"class":142,"line":171},[140,740,190],{"emptyLinePlaceholder":189},[140,742,743,745,747,749,751],{"class":142,"line":186},[140,744,196],{"class":153},[140,746,325],{"class":199},[140,748,203],{"class":153},[140,750,306],{"class":206},[140,752,210],{"class":157},[140,754,755,757,759],{"class":142,"line":193},[140,756,667],{"class":157},[140,758,311],{"class":164},[140,760,672],{"class":157},[140,762,763,766,769,772,775,778],{"class":142,"line":213},[140,764,765],{"class":157},"  WebSocket: WebSocket ",[140,767,768],{"class":153},"as",[140,770,771],{"class":199}," unknown",[140,773,774],{"class":153}," as",[140,776,777],{"class":153}," typeof",[140,779,780],{"class":157}," globalThis.WebSocket,\n",[140,782,783],{"class":142,"line":231},[140,784,234],{"class":157},[786,787,789],"h3",{"id":788},"unix-domain-sockets","Unix domain sockets",[84,791,792,793,795,796,803,804,807],{},"The proxy does not enforce any scheme allowlist — whatever the configured ",[100,794,102],{}," constructor accepts is accepted. For example, the ",[94,797,800],{"href":798,"rel":799},"https:\u002F\u002Fgithub.com\u002Fwebsockets\u002Fws",[98],[100,801,802],{},"ws"," package supports Unix domain sockets via its ",[100,805,806],{},"ws+unix:"," scheme:",[131,809,811],{"className":133,"code":810,"language":135,"meta":136,"style":136},"import { WebSocket } from \"ws\";\nimport { createWebSocketProxy } from \"crossws\";\n\nconst hooks = createWebSocketProxy({\n  target: \"ws+unix:\u002Fvar\u002Frun\u002Fbackend.sock:\u002Fchat\",\n  WebSocket: WebSocket as unknown as typeof globalThis.WebSocket,\n});\n",[100,812,813,825,837,841,853,862,876],{"__ignoreMap":136},[140,814,815,817,819,821,823],{"class":142,"line":143},[140,816,154],{"class":153},[140,818,717],{"class":157},[140,820,161],{"class":153},[140,822,722],{"class":164},[140,824,168],{"class":157},[140,826,827,829,831,833,835],{"class":142,"line":150},[140,828,154],{"class":153},[140,830,176],{"class":157},[140,832,161],{"class":153},[140,834,181],{"class":164},[140,836,168],{"class":157},[140,838,839],{"class":142,"line":171},[140,840,190],{"emptyLinePlaceholder":189},[140,842,843,845,847,849,851],{"class":142,"line":186},[140,844,196],{"class":153},[140,846,325],{"class":199},[140,848,203],{"class":153},[140,850,306],{"class":206},[140,852,210],{"class":157},[140,854,855,857,860],{"class":142,"line":193},[140,856,667],{"class":157},[140,858,859],{"class":164},"\"ws+unix:\u002Fvar\u002Frun\u002Fbackend.sock:\u002Fchat\"",[140,861,672],{"class":157},[140,863,864,866,868,870,872,874],{"class":142,"line":213},[140,865,765],{"class":157},[140,867,768],{"class":153},[140,869,771],{"class":199},[140,871,774],{"class":153},[140,873,777],{"class":153},[140,875,780],{"class":157},[140,877,878],{"class":142,"line":231},[140,879,234],{"class":157},[116,881,883],{"id":882},"forwarding-headers","Forwarding headers",[84,885,886,887,889,890,636,893,636,896,899],{},"Passing a ",[100,888,491],{}," option attaches extra headers to the upstream handshake. This is the usual way to forward identity (",[100,891,892],{},"cookie",[100,894,895],{},"authorization",[100,897,898],{},"origin",") or inject a shared secret to the upstream.",[131,901,903],{"className":133,"code":902,"language":135,"meta":136,"style":136},"import { WebSocket } from \"ws\";\nimport { createWebSocketProxy } from \"crossws\";\n\nconst hooks = createWebSocketProxy({\n  target: \"wss:\u002F\u002Fbackend.example.com\",\n  WebSocket: WebSocket as unknown as typeof globalThis.WebSocket,\n  headers: (peer) => ({\n    cookie: peer.request.headers.get(\"cookie\") ?? \"\",\n    \"x-forwarded-for\": peer.remoteAddress ?? \"\",\n  }),\n});\n",[100,904,905,917,929,933,945,953,967,983,1005,1019,1024],{"__ignoreMap":136},[140,906,907,909,911,913,915],{"class":142,"line":143},[140,908,154],{"class":153},[140,910,717],{"class":157},[140,912,161],{"class":153},[140,914,722],{"class":164},[140,916,168],{"class":157},[140,918,919,921,923,925,927],{"class":142,"line":150},[140,920,154],{"class":153},[140,922,176],{"class":157},[140,924,161],{"class":153},[140,926,181],{"class":164},[140,928,168],{"class":157},[140,930,931],{"class":142,"line":171},[140,932,190],{"emptyLinePlaceholder":189},[140,934,935,937,939,941,943],{"class":142,"line":186},[140,936,196],{"class":153},[140,938,325],{"class":199},[140,940,203],{"class":153},[140,942,306],{"class":206},[140,944,210],{"class":157},[140,946,947,949,951],{"class":142,"line":193},[140,948,667],{"class":157},[140,950,311],{"class":164},[140,952,672],{"class":157},[140,954,955,957,959,961,963,965],{"class":142,"line":213},[140,956,765],{"class":157},[140,958,768],{"class":153},[140,960,771],{"class":199},[140,962,774],{"class":153},[140,964,777],{"class":153},[140,966,780],{"class":157},[140,968,969,972,974,976,978,980],{"class":142,"line":231},[140,970,971],{"class":206},"  headers",[140,973,545],{"class":157},[140,975,548],{"class":351},[140,977,551],{"class":157},[140,979,554],{"class":153},[140,981,982],{"class":157}," ({\n",[140,984,985,988,990,992,995,997,1000,1003],{"class":142,"line":358},[140,986,987],{"class":157},"    cookie: peer.request.headers.",[140,989,372],{"class":206},[140,991,222],{"class":157},[140,993,994],{"class":164},"\"cookie\"",[140,996,551],{"class":157},[140,998,999],{"class":153},"??",[140,1001,1002],{"class":164}," \"\"",[140,1004,672],{"class":157},[140,1006,1007,1010,1013,1015,1017],{"class":142,"line":382},[140,1008,1009],{"class":164},"    \"x-forwarded-for\"",[140,1011,1012],{"class":157},": peer.remoteAddress ",[140,1014,999],{"class":153},[140,1016,1002],{"class":164},[140,1018,672],{"class":157},[140,1020,1021],{"class":142,"line":405},[140,1022,1023],{"class":157},"  }),\n",[140,1025,1026],{"class":142,"line":431},[140,1027,234],{"class":157},[1029,1030,1031],"important",{},[84,1032,1033,1034,1036,1037,1040,1041,1043,1044,1046,1047,1051,1052,1057,1058,1065],{},"\nThe WHATWG global ",[100,1035,102],{}," constructor does ",[250,1038,1039],{},"not"," accept custom headers. ",[100,1042,491],{}," is only honored when a ",[100,1045,102],{}," constructor that takes a third options argument is passed via the ",[94,1048,1049,109],{"href":106},[100,1050,102],{}," — e.g. ",[94,1053,1055],{"href":798,"rel":1054},[98],[100,1056,802],{}," or ",[94,1059,1062],{"href":1060,"rel":1061},"https:\u002F\u002Fundici.nodejs.org",[98],[100,1063,1064],{},"undici",". With the global constructor the option is silently ignored.",[116,1067,1069],{"id":1068},"api","API",[786,1071,1073],{"id":1072},"createwebsocketproxytarget",[100,1074,1075],{},"createWebSocketProxy(target)",[84,1077,1078,1079,1057,1082,1085],{},"Accepts either a target URL (",[100,1080,1081],{},"string",[100,1083,1084],{},"URL","), a resolver function, or an options object:",[1087,1088,1089,1115,1132,1145,1167,1186],"ul",{},[1090,1091,1092,1096,1097,1100,1101,1103,1104,1106,1107,1109,1110,1114],"li",{},[250,1093,1094],{},[100,1095,631],{}," — ",[100,1098,1099],{},"string | URL | (peer: Peer) => string | URL",". The upstream WebSocket URL, or a function that resolves it per peer. The proxy does not enforce a scheme allowlist; any URL the configured ",[100,1102,102],{}," constructor accepts (including ",[100,1105,806],{}," with ",[100,1108,802],{},") works. See the ",[94,1111,1113],{"href":1112},"#dynamic-target","SSRF warning"," before using a dynamic resolver.",[1090,1116,1117,1096,1121,1124,1125,1128,1129,1131],{},[250,1118,1119],{},[100,1120,694],{},[100,1122,1123],{},"boolean"," (default ",[100,1126,1127],{},"true","). When enabled, the client's ",[100,1130,650],{}," header is forwarded to the upstream and echoed back in the upgrade response. Values that are not valid RFC 7230 tokens are dropped.",[1090,1133,1134,1096,1138,1141,1142,1144],{},[250,1135,1136],{},[100,1137,491],{},[100,1139,1140],{},"HeadersInit | (peer: Peer) => HeadersInit",". Extra headers to send on the upstream handshake. Only honored when a custom ",[100,1143,102],{}," constructor that accepts a third options argument is supplied — the WHATWG global ignores it.",[1090,1146,1147,1096,1152,1124,1155,1158,1159,1162,1163,1166],{},[250,1148,1149],{},[100,1150,1151],{},"maxBufferSize",[100,1153,1154],{},"number",[100,1156,1157],{},"1048576",", i.e. 1 MiB). Maximum number of bytes buffered per peer while the upstream is still connecting. String frames are accounted at their UTF-8 worst case (3 bytes per UTF-16 code unit) to avoid undercounting multi-byte content. When exceeded, the peer is closed with code ",[100,1160,1161],{},"1009"," (Message Too Big). Set to ",[100,1164,1165],{},"0"," to disable.",[1090,1168,1169,1096,1174,1124,1176,1179,1180,1183,1184,1166],{},[250,1170,1171],{},[100,1172,1173],{},"connectTimeout",[100,1175,1154],{},[100,1177,1178],{},"10000","). Milliseconds to wait for the upstream WebSocket handshake to complete. If exceeded, the peer is closed with code ",[100,1181,1182],{},"1011",". Set to ",[100,1185,1165],{},[1090,1187,1188,1096,1192,1124,1195,1198,1199,1201],{},[250,1189,1190],{},[100,1191,102],{},[100,1193,1194],{},"typeof WebSocket",[100,1196,1197],{},"globalThis.WebSocket","). Custom ",[100,1200,102],{}," constructor used to dial the upstream. Falls back to the global when omitted; throws at setup time if neither is available.",[84,1203,1204,1205,1207,1208,636,1210,636,1213,636,1216,1219,1220,1223],{},"Returns a ",[100,1206,128],{}," object containing ",[100,1209,259],{},[100,1211,1212],{},"open",[100,1214,1215],{},"message",[100,1217,1218],{},"close",", and ",[100,1221,1222],{},"error"," hooks.",[1225,1226,1227],"style",{},"html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sQHwn, html code.shiki .sQHwn{--shiki-light:#E36209;--shiki-default:#FFAB70;--shiki-dark:#FFAB70}",{"title":136,"searchDepth":150,"depth":150,"links":1229},[1230,1231,1232,1233,1234,1237,1238],{"id":118,"depth":150,"text":119},{"id":264,"depth":150,"text":265},{"id":495,"depth":150,"text":496},{"id":643,"depth":150,"text":644},{"id":698,"depth":150,"text":699,"children":1235},[1236],{"id":788,"depth":171,"text":789},{"id":882,"depth":150,"text":883},{"id":1068,"depth":150,"text":1069,"children":1239},[1240],{"id":1072,"depth":171,"text":1075},"Forward incoming WebSocket connections to an upstream ws:\u002F\u002F or wss:\u002F\u002F target.","md",{"icon":40},{"icon":40},{"title":37,"description":1241},"15vxzUsocHiwwSgUcZvcbCRM5Wnqif5ihXGADTeNV4k",[1248,1249],{"title":32,"path":33,"stem":34,"description":136,"icon":35,"children":-1},{"title":42,"path":43,"stem":44,"description":136,"icon":47,"children":-1},1775860078160]