node.js - Why can HTML opened with file protocol connect to websocket?
迷茫2017-05-16 13:39:14
0
2
655
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.
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)
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.
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)
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.