javascript - 使用 Ctrl+C 终止运行 Vue.js 的 webpack 后,sockjs-node Cross-Origin Request Blocked 警告

标签 javascript node.js vue.js webpack webpack-dev-server

使用 Django 和 Vue.js 开发应用程序。我在 https://localhost:8000 上运行网站,在端口 8080 上运行前端作为本地 https 网格实例。在设置 header 之前,我不断收到每个 HTTP 请求的这种类型的 CORS 错误:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]


通过在 webpack 配置文件中附加以下 header 来解决此问题:
headers: {
   "Access-Control-Allow-Origin" : "*",
   "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
},
我还添加了带有 key 、证书和证书颁发机构的 https。
在此之后,错误基本上消失了。但是,每当我 Ctrl+C 我的开发服务器时,我都会以 1-2-4-8-16-32-64-128-... 秒为增量收到上述错误,如下所示:

[WDS] Disconnected!

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://u-redwood-testapplicationfrontend.grid.locked.com:8080/sockjs-node/info?t=1594916128605. (Reason: CORS request did not succeed). [Learn More]


这是正常行为吗?这是 CORS 发送的某种 Keep-Alive 吗?
任何帮助,将不胜感激。
谢谢!

最佳答案

对我来说运行npm run build/vue-cli-service build然后重启serve过程解决了这个问题。
在切换我正在工作的网络时,这似乎发生在我身上——虽然不完全确定解释是什么。

关于javascript - 使用 Ctrl+C 终止运行 Vue.js 的 webpack 后,sockjs-node Cross-Origin Request Blocked 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62944640/

相关文章:

javascript - 与您的操作系统或架构不兼容 : fsevents@1. 0.11

node.js - npm 是否缓存包?

css - vue-js元素中为不同的组件设置不同的css样式

javascript - Vue prop 在对计算函数的初始调用中未定义

javascript - 当在选择项中找不到模型值时,将类添加到输入

javascript - 在 Node.js 中处理滴答(或堆栈)之间的异常的策略?

javascript - HTML5 确定放置对象

vue.js - `moxios.wait` 使用 Jest、Vue Test Utils 和 Moxios 测试 VueJS 时从不执行

javascript - html 在 angular.js 中选择选项如何做出正确的 ng if?

javascript - 循环期间的函数调用错误地返回未定义