Search code examples
reactjsserverproxylocalhosthttp-proxy-middleware

Error occurred while proxying request - CERT_HAS_EXPIRED


After spending some considerable amount of time trying to solve this, here I am seeking some help about this issue.

Problem

[HPM] Error occurred while proxying request localhost:3000/auth/authentication-api/clinic/user/login to https://xyxyx.clinic/ [CERT_HAS_EXPIRED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

So I am not able to to make a POST request of the 'login credentials body data; to the https://xyxyx.clinic/ path and also getting a 500 Internal Server Error in the browser's network tab inside the dev tools.

What I have done so far to solve this

  • Checked the validity of the certificate and YES it is valid.
  • Upgraded the Nodejs from v8.x.x to V.16.1.4 as per this question (https://stackoverflow.com/a/69403683/13406292)
  • Cleared the node_modules several time, installed dependencies again, even tried restarting and completed my Linux Manjaro updates.
  • Rechecked all of my proxy server codes and tested all the backend api endpoints - all were worked well.

enter image description here

My findings

I asked someone else to run this repo in their PC and it was working well - they could log in and out. Am I missing any steps something here ??


Solution

  • ANSWER

    Adding "secure:false" solved the issue. So basically secure="false" means requests from both HTTP and HTTPS are allowed.

    app.use(
    '/api',
    createProxyMiddleware({
      target: 'https://xyxy.clinic/',
      changeOrigin: true,
      secure: false,
    }),
    

    )