Languages
[Edit]
EN

Node.js - run npm project with unauthorized certificates accepting

9 points
Created by:
Root-ssh
96980

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": {
    // ...
  }
}
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join