主机:localhost。 不在证书的altnames中

服务器端渲染时出现错误。

RENDERING ERROR: { [Error: Network error: request to https://api-dev.xyz.io/graphql failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:*.xyz.io"] graphQLErrors: null, networkError: { [FetchError: request to https://api-dev.xyz.io/graphql failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:*.xyz.io"] name: 'FetchError', message: 'request to https://api-dev.xyz.io/graphql failed, reason: Hostname/IP doesn\'t match certificate\'s altnames: "Host: localhost. is not in the cert\'s altnames: DNS:*.xyz.io"', type: 'system', errno: undefined, code: undefined }, message: 'Network error: request to https://api-dev.xyz.io/graphql failed, reason: Hostname/IP doesn\'t match certificate\'s altnames: "Host: localhost. is not in the cert\'s altnames: DNS:*.xyz.io"', extraInfo: undefined } 

注意: –我正在使用react,readux,apollo-client(GraphQL)和ExpressJS(NodeJS)。 我要求的API服务器在其他域上,我不能做任何改变。

虽然使用客户端渲染我没有面临任何困难,一切都按照预期工作,但在做服务器端渲染时,我得到以上错误。

所以我尝试了以下方法在我的服务器上,但仍然没有运气。

  1. 添加自签名证书
  2. 在https选项中添加“rejectUnauthorized”:false。 const options = { 'key': key, 'cert': cert, 'ca': [ fs.readFileSync('local-certificate.pem') ], 'rejectUnauthorized':false };

    https.createServer(options,app).listen(httpsPort,'0.0.0.0',function onStart(err){if(err){console.log(err);} console.info('==> s。在你的浏览器中打开http://0.0.0.0:%s/',httpsPort,options );});

  3. 另外,我尝试在我的自签名证书中添加altname, 如何使用OpenSSL生成带有SubjectAltName的自签名证书?

有没有办法绕过证书validation,以便我的快递服务器可以向另一个具有有效证书的域上的API服务器发出请求。

我仍然不确定是否可以通过在我的快速服务器上进行任何更改来解决问题。

请让我知道这一点的任何见解。