codeSandBox (React/Node) 的 Http 请求错误

2023-12-26

我在 CodeSandBox/StackBlitz 等在线 IDE 中遇到奇怪的错误。 我做了一个示例 http 请求(使用 axios 但使用 fetch 或其他问题是相同的)并尝试在控制台中打印响应。 我在前端使用 React,在后端使用 Node(监听端口 8080), 当我使用 npm start (localhost:3000 和 http 请求http://[public ip]:8080/coucou)

此处反应代码(请求位于 Main.js 文件中):https://codesandbox.io/s/ww28ry45pl https://codesandbox.io/s/ww28ry45pl

当我刚放的时候http://[public ip]:8080/coucou这工作正常,我得到了服务器的良好响应。

这里是 codeSandBox 中服务器返回的错误(由 catch 块捕获):

错误{堆栈: “创建错误@https://ww28ry45pl.codesandbox.io/node_modules/axios/lib/core/createError.js:16:15 https://ww28ry45pl.codesandbox.io/node_modules/axios/lib/core/createError.js:16:15处理错误@https://ww28ry45pl.codesandbox.io/node_modules/axios/lib/adapters/xhr.js:87:14 https://ww28ry45pl.codesandbox.io/node_modules/axios/lib/adapters/xhr.js:87:14 "}

我还没有找到任何关于这个问题的信息。


这是因为您正在制作一个HTTP从安全通信点(codesandbox)进行呼叫。您可以简单地使用/添加https在你的公众身上URL它会起作用的。通过 HTTPS 页面的 HTTP Ajax 请求 https://stackoverflow.com/questions/4032104/http-ajax-request-via-https-page

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

codeSandBox (React/Node) 的 Http 请求错误 的相关文章

随机推荐