在我的客戶機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