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:
xxxxxxxxxx
1
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.
It is necessary to indicate the script was want to run. In our case, it will be devServer
located in the scripts
property.
xxxxxxxxxx
1
NODE_TLS_REJECT_UNAUTHORIZED=0 npm run devServer
package.json
file example:
xxxxxxxxxx
1
{
2
"name": "my-application",
3
"version": "1.0.0",
4
"description": "My example backend",
5
"license": "Apache-2.0",
6
"author": "John",
7
"main": "server.js",
8
"scripts": {
9
"devServer": "npm run startWithNodemon -- server.js"
10
},
11
"dependencies": {
12
// ...
13
},
14
"devDependencies": {
15
// ...
16
}
17
}