search

Home  >  Q&A  >  body text

node.js - Why can HTML opened with file protocol connect to websocket?

The server is built with Nodejs, and the client is opened in Google Chrome using the file protocol, and the data can be successfully connected and returned.

迷茫迷茫2838 days ago760

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-05-16 13:41:14

    The browser does not require that the page and the URL of the wss connection have the same origin (if necessary, you can still check the Origin on the server and reject such a connection)

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:41:14

    It is true that Websocket is over HTTP, but it does not mean that it must be over HTTP for the page you get. When you open the file, js executes the connection and creates a new tcp connection for handshake.

    reply
    0
  • Cancelreply