问题
Using Aurelia, backed is using self signed certificate and NodeJS refuses to forward requests over HTTPS if the certificate is not trusted.
[HPM] Error occurred while trying to proxy request /rest/open/test/test-por
tal-url=abcdsdf/ui-settings from localhost:9000 to https://localhost:9443
(DEPTH_ZERO_SELF_SIGNED_CERT)
(https://nodejs.org/api/errors.html#errors_common_system_errors)
Tried process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; but I'm getting "process is not defined". Also, tried to set environmental variable but no go.
回答1:
While configuring middleware, browserSync>server>middleware, used secure: false
property to fix this issue.
middleware.push(proxy('/test-portal/rest', {
target: environmentConfig.testApi,
secure: false,
logLevel: 'debug',
changeOrigin: true
}));
来源:https://stackoverflow.com/questions/48097156/trust-self-signed-certificates-node-js-aurelia