Load Nuxt project to exist express app

假如想象 提交于 2019-12-13 03:15:49

问题


Could not find a trace over the network.

Is there a way to load Nuxt project as a middleware for other express server?

The documentation is just explaining how to run the nuxt-server. (I'm familiar with the 'static' option, but I would like to keep the SSR behavior)

I've transferred my Vue (non-nuxt) application to Nuxt, so I already have a server infrastructure that the nuxt-production-server is interrupting, so I would like to load a build or middleware to my existing express server.

Thanks in advance.


回答1:


Yes, it's possible. See official nuxt template -> https://github.com/nuxt-community/express-template

Or you can use something like this

const { Nuxt } = require('nuxt')
const config = require('./nuxt.config.js')
const nuxt = new Nuxt(config)
const app = require('express')()
app.use((req, res) => setTimeout(() => {
  return nuxt.render(req, res)
}, 0))
app.listen(port, '0.0.0.0')


来源:https://stackoverflow.com/questions/51459797/load-nuxt-project-to-exist-express-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!