title: SSL settings for Nginx + express
body: <p>I am building a web server using Nginx and express.</p>
  <p>By redirecting requests from port 80 to port 443, Nginx only allows encrypted connections.
  And Port 443 forwards the request to express.</p>
  <p>Nginx's conf settings are:</p>
  <pre><code>server {
      listen 80;
      server_name api.domain.com;
      return 301 https://$host$request_uri;
  }
  
  server {
      listen 443 ssl;
      server_name api.domain.com;
  
      ssl_certificate /path
      ssl_certificate_key /path
  
      ...
  
      location / {
          proxy_pass http://localhost:3000;
      }
  }
  </code></pre>
  <p>express uses CORS middleware.</p>
  <pre><code>var app = express();
  
  var cors = require('cors');
  app.use(cors());
  
  var server = http.createServer(app).listen(3000, 'localhost', function() { ... });
  </code></pre>
  <p>I tried something like <a href="https://www.steemcoinpan.com/sct/@morning/express-nginx-proxy-ssl-websocket" rel="nofollow noreferrer">https://www.steemcoinpan.com/sct/@morning/express-nginx-proxy-ssl-websocket</a>, but it still doesn't work.</p>
  <p>What settings do I need?</p>
  <p>※ Added</p>
  <p>If I call an API like 'http://api.domain.com/login', [Access to XMLHttpRequest at'http://api.domain.com/login' from origin'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.] error message is displayed.</p>