Closed duqigit closed 7 years ago
Hi! In order to debug through your issue, please provide all the following information:
Thanks!
Thanks
Node.js Version :v9.2.0 express Version :4.15.3
servier.js
import express from 'express' import { Nuxt, Builder } from 'nuxt'
import api from './api'
const app = express() const host = process.env.HOST || '106.14.133.247' const port = process.env.PORT || 80
app.set('port', port)
// Import API Routes app.use('/api', api)
// Import and Set Nuxt.js options let config = require('../nuxt.config.js') config.dev = !(process.env.NODE_ENV === 'production')
// Init Nuxt.js const nuxt = new Nuxt(config)
// Build only in dev mode if (config.dev) { const builder = new Builder(nuxt) builder.build() }
// Give nuxt middleware to express app.use(nuxt.render) // Listen the server app.listen(port) console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
and Listen :3000 is ok:
but Listen :80is error:
@dougwilson
I'm not sure I understand. If it works fine on 3000, but then you change the server code to lusten on port 80, then of course you'll get an error when you now try to connect to port 3000. You need yo connect to port 80 if you listen on port 80.
What do I need to do? @dougwilson
@18717700273 if you want to listen on port 80, you should use a reverse proxy like nginx to do it.
This seems to be from the nuxt.js you are using, and not related to Express. I suggest either removing nuxt.js or posting on the nuxt.js support. From your screenshot you are connecting to port 80 fine but then something in nuxt.js is still trying to connect to port 3000.