简体   繁体   English

提取Api无法加载Webpack

[英]Fetch Api cannot load webpack

I'm using next js 8 version in relation with react. 我正在使用与React相关的下一个js 8版本。 Also using Apollo and Graphql. 还使用Apollo和Graphql。 But I don't think that problem is in Apollo or Graphql. 但是我不认为问题出在Apollo或Graphql中。 I have _document.js file in my pages folder. 我的页面文件夹中有_document.js文件。 But when using Router.back() I have error about fetch api webpack and cors request. 但是当使用Router.back()时,我对获取api webpack和cors请求有错误。 Actual problem is like this in browser console: 实际问题是在浏览器控制台中这样的:

Fetch API cannot load webpack://%5Bname%5D_%5Bchunkhash%5D/./node_modules/react/cjs/react.development.js?. 提取API无法加载webpack://%5Bname%5D_%5Bchunkhash%5D/./node_modules/react/cjs/react.development.js?。 URL scheme must be "http" or "https" for CORS request. 对于CORS请求,URL方案必须为“ http”或“ https”。

I think you are calling an endpoint without the protocol, for example you are doing 我认为您正在调用没有协议的端点,例如您正在执行

fetch('localhost:3000/my-endpoint')

You need to set put the http or https 您需要设置放置http或https

fetch('http://localhost:3000/my-endpoint')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM