Static GitHub Issues

[2014] [Help wanted] Enabling https

prev: Unable to generate static HTML files in SPA mode.
next: layouts and double initialize component

Hello,

I use nuxt.js programmatically on my live server, but I am unable to get it working with https. Surfing to the https address gives me a 502 bad gateway error from nginx (engintron). Other https sites on the server work fine (without nuxt), but I don't know how to fix this for a nuxt.js application. Doesn't work with/without Cloudflare, same 502 error.

if ($host ~ "domain.com") {
 set $PROXY_DOMAIN_OR_IP "xxx.xx.xx.x";
 set $PROXY_TO_PORT 3000;
}
const { Nuxt, Builder } = require('nuxt')

const app = require('express')()
const isProd = (process.env.NODE_ENV === 'production')
const port = process.env.PORT || 3000

// We instantiate nuxt.js with the options
const config = require('./nuxt.config.js')
config.dev = !isProd
const nuxt = new Nuxt(config)

// Render every route with Nuxt.js
app.use(nuxt.render)

// Build only in dev mode with hot-reloading
if (config.dev) {
  new Builder(nuxt).build()
  .then(listen)
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })
}
else {
  listen()
}

function listen() {
  // Listen the server
  app.listen(port, '0.0.0.0')
  console.log('Server listening on `localhost:' + port + '`.')
}
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1789">#c1789</a>)</em></sub></div>