3

I have XM Cloud running locally in a docker container. This means with self-signed certificates.

When I use JSS to create and deploy the JSS Style guide application, I keep getting the following error when starting my JSS application on http://localhost:3000: FetchError: request to https://xmcloudcm.localhost/sitecore/api/graph/edge failed, reason: unable to verify the first certificate

enter image description here

With the built-in GraphiQL explorer on URL https://xmcloudcm.localhost/sitecore/api/graph/edge/ui I can execute GraphQL queries on the endpoint https://xmcloudcm.localhost/sitecore/api/graph/edge.

This does not work with Insomnia offline GraphQL API client, I get the following error

Insomnia error

When I disable validate certificates in the settings of Insomnia it works:

Insomnia settings

I tried to set the environment variable ENV NODE_TLS_REJECT_UNAUTHORIZED "0" in the Dockerfile for the CM server, but that did not help.

Any ideas to get this working in an docker containers based environment with self-signed certificates?

2
  • Can you include texts from your screenshots as code blocks? That helps with SEO and therefore helps others to find your question and answer.
    – Marek Musielak
    Commented Oct 13, 2022 at 10:19
  • 1
    You really should be using the docker hosted rendering host for this. Then you wouldn't get any certificate errors. Did you use the XM Cloud Starter template to create your starting repo?
    – Richard Seal
    Commented Oct 13, 2022 at 16:13

2 Answers 2

2

Ah blizz! I shouldn't set the environment variable NODE_TLS_REJECT_UNAUTHORIZED to 0 on the XM Cloud CM server (in the Docker container), but on my dev machine where I run jss start:connected. Now it works!!

1
  • Once you added NODE_TLS_REJECT_UNAUTHORIZED=0 to your environment variables did you then encounter another issue where the site displays correctly but shows errors stating that the CPD "clientKey" is required? Commented May 18, 2023 at 10:00
2

We also got this error and the reason is - if you do not have privately signed certificates configured correctly, you will see errors when running your JSS (front-end) application.

It is related to adding a certificate to Node.js with a NODE_EXTRA_CA_CERTS environment variable.

To include your certificates in the Node.js environment, you must add them to the well-known root certificates of Node.js.

The certificate is in PEM format and is called rootCA.pem by default. Your file path will look something like C:\Users\<username>\AppData\Local\mkcert\rootCA.pem.

Run the below command in the terminal -

setx NODE_EXTRA_CA_CERTS C:\Users\<username>\AppData\Local\mkcert\rootCA.pem

The error should be resolved if you try to run your front-end website now. But it was still not working for us, so we added the variable below to our .env file -

NODE_TLS_REJECT_UNAUTHORIZED=0

After adding this the error was gone and we see the website up and running.

For reference - https://sitecorerocksblog.wordpress.com/2024/08/05/unable-to-verify-the-first-certificate/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.