Create-react-app: CERT_HAS_EXPIRED issue when I try to use proxy with https request

Created on 8 Feb 2018  路  3Comments  路  Source: facebook/create-react-app

Is this a bug report?

maybe yes

I get this error

    Proxy error: Could not proxy request /api/islogged from localhost:3000 to https://www.example.com.
    See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (CERT_HAS_EXPIRED).

if the proxy in the package.json is configured in this way:

      "proxy": {
        "/api-rc": {
          "target": "https://www.example.com",
          "pathRewrite": {
            "^/api-rc": "/api"
          }
        }

I tried to resolve it in two ways:

    if(process.env.NODE_ENV === 'development'){    
        process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
    }

and

    export const get = (url, params) => 
        const agent = new https.Agent({
            rejectUnauthorized: false
        });

        const p = params ? {httpsAgent: agent, params: {...params}} : {};

        return axios.get(url, p)
    };

but the error is still there . Am I wrong something?

Most helpful comment

Have you tried adding changeOrigin: true and/or secure: false?

All 3 comments

Have you tried adding changeOrigin: true and/or secure: false?

Thank you..now it works

@Nide83 glad to help. You may close this issue in case your problem was resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaveLindberg picture DaveLindberg  路  3Comments

jnachtigall picture jnachtigall  路  3Comments

alleroux picture alleroux  路  3Comments

ap13p picture ap13p  路  3Comments

Aranir picture Aranir  路  3Comments