title: NodeJS + Express using fetch(): How to bypass "Your connection is not private" in Javascript?
body: <p>Currently I have a NodeJS + ExpressJS client-side server set up and it makes API calls to the back-end server. But whenever I do, I first would have to go directly to the URL of the API back-end server and view the following page, and go to <code>Advanced</code> -> <code>Proceed to https://backendserver.com:8080 (Unsafe)</code>, in order to be able to make the API call without any error.</p>
  
  <p><a href="https://i.stack.imgur.com/tT0OS.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/tT0OS.jpg" alt="enter image description here"></a></p>
  
  <p>Is there a way to always allow it to <code>Proceed to https://backendserver.com:8080</code> without having to manually do it via browser? </p>
  
  <p>Here is how I make the API call with <code>fetch()</code>:</p>
  
  <pre><code>  loggingIn(userInfo) {
  
      var userInfoBody = {
          'username': `${userInfo.username}`,
          'password': `${userInfo.password}`
      }
  
      var configuration = {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(userInfoBody)
      }
  
      return function(dispatch) {
        fetch('https://backendserver.com:8080/creds', configuration)
        .then(response =&gt; response.json())
        .then(response =&gt; {
          console.log('Success and response is', response)
        })
        .catch((error) =&gt; {
          console.log("Error: ", error)
        })
      }
  </code></pre>
  
  <p>And my NodeJS + Express is set up like so:</p>
  
  <pre><code>var express = require('express');
  var cors = require('cors');
  var path = require('path');
  var config = require('../webpack.config.js');
  var webpack = require('webpack');
  var webpackDevMiddleware = require('webpack-dev-middleware');
  var webpackHotMiddleware = require('webpack-hot-middleware');
  var app = express();
  var compiler = webpack(config);
  
  app.use(cors());
  
  app.use(webpackDevMiddleware(compiler, {noInfo: true, publicPath: config.output.publicPath}));
  
  app.use(webpackHotMiddleware(compiler));
  
  app.use(express.static('./dist'));
  
  app.use('/', function (req, res) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    res.sendFile(path.resolve('client/index.html'))
  })
  
  var port = 3000;
  
  app.listen(port, function(error) {
    if (error) throw error;
    console.log("Listening to ", port);
  })
  </code></pre>