everyone: I am a beginner on fort-end, create a single html file on disk.For example,"D:/index.html". Then I start a node.js server。
Run the node.js server, and open the browser on page of "index.html", CORS error occur. I know add js code " res.setHeader( "Access-Control-Allow-Origin", "*" );" on node.js server, it can avoid CORS error. My question is "single html page located on disk, I think it also come from localhost, why request to localhost server can trigger CORS???"
when we say the same origin the port, protocol, and the host should be the same for both. please check https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy