JavaScript/websocket/socket.io:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
 
(未显示同一用户的1个中间版本)
第38行: 第38行:


== 示例 ==
== 示例 ==
后端。
后端。将 socket.io 挂载到 http 服务上。
{{Codetab|tabs=<tabs>
{{Codetab|tabs=<tabs>
<tab name="socket.ts"><syntaxhighlight lang="javascript">
<tab name="socket.ts"><syntaxhighlight lang="javascript">
第217行: 第217行:
</syntaxhighlight></tab>
</syntaxhighlight></tab>
</tabs>}}
</tabs>}}
== nginx ==
<pre>
location /socket.io/ {       
  proxy_pass http://127.0.0.1:8080;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_http_version 1.1;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $host;
}</pre>
== other ==
== other ==
* https://socket.io/docs/v4/handling-cors/
* https://socket.io/docs/v4/handling-cors/