EN
Node.js - run npm project with unauthorized certificates accepting
9
points
In this short article, we would like to show how to run Node.js application with ignoring/accepting unauthorized certificates (lets to create HTTPS connections with untrusted addresses).
Quick solution:
NODE_TLS_REJECT_UNAUTHORIZED=0 npm run script_name_here_from_package_json
Where:
NODE_TLS_REJECT_UNAUTHORIZED=0
permits to create HTTPS connections with untrusted addresses - useful in development mode.
Practical example
It is necessary to indicate the script was want to run. In our case, it will be devServer
located in the scripts
property.
NODE_TLS_REJECT_UNAUTHORIZED=0 npm run devServer
package.json
file example:
{
"name": "my-application",
"version": "1.0.0",
"description": "My example backend",
"license": "Apache-2.0",
"author": "John",
"main": "server.js",
"scripts": {
"devServer": "npm run startWithNodemon -- server.js"
},
"dependencies": {
// ...
},
"devDependencies": {
// ...
}
}