rejectUnauthorized: false 在 ApolloClient 中未被识别
rejectUnauthorized: false not being recognized in ApolloClient
我当前的设置是:
import {
ApolloClient,
ApolloProvider,
gql,
HttpLink,
} from '@apollo/client';
import fetch from 'node-fetch';
import { Agent } from 'https';
...
const agent = new Agent({
rejectUnauthorized: false,
});
const httpLink = new HttpLink({
uri: process.env.REACT_APP_GRAPHQL_URL,
fetch: fetch,
fetchOptions: {
agent: agent
},
});
...
const client = new ApolloClient({
link: httpLink,
cache: cache,
typeDefs,
connectToDevTools: true,
});
...
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
当我 useQuery
我得到 createHttpLink.ts:121 POST https://*****.test/wp/graphql net::ERR_CERT_INVALID
。据我所知,这是当前使用自签名证书的方式,但它似乎不起作用。否则我找不到任何文件。我当前的实施似乎忽略了拒绝有什么问题?
这不是一个完整的答案,但我还是将其标记为已解决。它与 Apollo Client 或 node-fetch 无关,我在 Chrome(具体来说是 MacOS)中对此进行了测试,它 拒绝了 self-signed证书。我现在只是继续使用 Firefox 进行开发,因为它会接受证书。代理 属性 在开发工具中仍然显示为空,所以这可能是一个转移注意力的问题?不确定,但我现在可以继续。
我当前的设置是:
import {
ApolloClient,
ApolloProvider,
gql,
HttpLink,
} from '@apollo/client';
import fetch from 'node-fetch';
import { Agent } from 'https';
...
const agent = new Agent({
rejectUnauthorized: false,
});
const httpLink = new HttpLink({
uri: process.env.REACT_APP_GRAPHQL_URL,
fetch: fetch,
fetchOptions: {
agent: agent
},
});
...
const client = new ApolloClient({
link: httpLink,
cache: cache,
typeDefs,
connectToDevTools: true,
});
...
ReactDOM.render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.getElementById('root')
);
当我 useQuery
我得到 createHttpLink.ts:121 POST https://*****.test/wp/graphql net::ERR_CERT_INVALID
。据我所知,这是当前使用自签名证书的方式,但它似乎不起作用。否则我找不到任何文件。我当前的实施似乎忽略了拒绝有什么问题?
这不是一个完整的答案,但我还是将其标记为已解决。它与 Apollo Client 或 node-fetch 无关,我在 Chrome(具体来说是 MacOS)中对此进行了测试,它 拒绝了 self-signed证书。我现在只是继续使用 Firefox 进行开发,因为它会接受证书。代理 属性 在开发工具中仍然显示为空,所以这可能是一个转移注意力的问题?不确定,但我现在可以继续。