在我的客户机App下面的代码:“只有HTTP支持跨源请求。”与Node.js的
const socket = io('${location.protocol}//${location.hostname}:8090');
是给我下面的错误在我的浏览器:
XMLHttpRequest cannot load http://${location.protocol}/socket.io/?EIO=3&transport=polling&t=LRLUtss. Cross origin requests are only supported for HTTP.
我的客户端代码如何使用Node.js通过npm start
所以运行当我更新我的代码时,“http://localhost:3000”在我的浏览器中自动刷新。
似乎'$ {location.protocol}'没有被替换为字符串。 – jfriend00
@ jfriend00多数民众赞成在我的想法。为什么会这样? – Baz
也许浏览器不支持模板文字ES6功能? – jfriend00