I'm getting the below error while 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'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 }
Note:- I'm using react, redux, apollo-client(GraphQL) and ExpressJS(NodeJS). The API server to which I'm making the request is on another domain and I can't make any change on that.
While working with client-side rendering I'm not facing any difficulties everything is working as intended but while doing server-side render I'm getting the above error.
So I tried the below approaches on my server but still no luck.
Adding self-signed certificate
Adding 'rejectUnauthorized':false in https options.
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); });
Also I tried to add an alt name in my self-signed certificate with the help of How can I generate a self-signed certificate with SubjectAltName using OpenSSL?
Is there any way to bypass certificate verification so that my express server can make a request to the API server which is on another domain with a valid certificate?
I'm still a bit unsure whether I can fix it by making any changes at my end (on my express server).
Please let me know any insights on this.