Host: localhost. not in cert names

I get below errors when doing server side rendering.

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

Note: I use response, readux, apollo-client (GraphQL) and ExpressJS (NodeJS). The API server to which I am executing the request belongs to a different domain, and I cannot make any changes.

When working with client-side rendering, I don’t encounter any difficulties, everything works as expected, but when I render on the server side, I get the above errors.

So, I tried the approaches on my server, but still no luck.

  • Adding a self-signed certificate
  • Adding 'rejectUnauthorized': false in https settings. 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('== > Listening on httpsPort %s. Open up http://0.0.0.0:%s/ in your browser.', httpsPort, options); });

  • altname SubjectAltName OpenSSL?

, - API, .

, , - ( -).

, - .

+4

Source: https://habr.com/ru/post/1669253/


All Articles