Javascript apollo graphql突变-JSON输入意外结束

Javascript apollo graphql突变-JSON输入意外结束,javascript,reactjs,graphql,apollo,apollo-client,Javascript,Reactjs,Graphql,Apollo,Apollo Client,我正在使用@apollo/react hooks进行一个简单的测试,我得到了以下错误: ApolloError.ts:46 Uncaught (in promise) Error: Network error: Unexpected end of JSON input at new ApolloError (ApolloError.ts:46) at Object.error (QueryManager.ts:255) at notifySubscription (Obs

我正在使用
@apollo/react hooks
进行一个简单的测试,我得到了以下错误:

ApolloError.ts:46 Uncaught (in promise) Error: Network error: Unexpected end of JSON input
    at new ApolloError (ApolloError.ts:46)
    at Object.error (QueryManager.ts:255)
    at notifySubscription (Observable.js:140)
    at onNotify (Observable.js:179)
    at SubscriptionObserver.error (Observable.js:240)
    at observables.ts:15
    at Set.forEach (<anonymous>)
    at Object.error (observables.ts:15)
    at notifySubscription (Observable.js:140)
    at onNotify (Observable.js:179)
    at SubscriptionObserver.error (Observable.js:240)
    at Object.error (index.ts:81)
    at notifySubscription (Observable.js:140)
    at onNotify (Observable.js:179)
    at SubscriptionObserver.error (Observable.js:240)
    at httpLink.ts:184

我不知道为什么会出现此错误。

代码没有问题,是后端没有CORS配置

这是一个ruby服务器,机架cors没有配置

在后端修复后,我还将apollo客户端更改为:

从“apollo boost”导入apollo客户端;
const客户端=新客户端({
uri:,
标题:{
“内容类型”:“应用程序/json”,
“访问控制允许来源”:“*”,
“访问控制允许凭据”:true,
},
取来
});
导出默认客户端;
删除了获取选项模式:“无COR”:

fetchOptions:{
模式:“无cors”,
}
import React from 'react';
import { ApolloProvider } from '@apollo/react-hooks';
import Authenticating from './Authenticating';
import apolloClient from './apolloClient';

const App = () => {
   <ApolloProvider client={apolloClient}>
      <Authenticating/>
   </ApolloProvider>
}

export default App;