【问题标题】:Nuxt ssr with firebase hosting and functions具有 Firebase 托管和功能的 Nuxt ssr
【发布时间】:2018-06-12 01:05:48
【问题描述】:

我使用 nuxt 创建了我的应用,我想通过 Firebase 托管进行部署。

所以我编辑了我的 firebase.json

{
  "hosting": {
    "public": "./",
    "ignore": [
      "firebase.json",
      "testssr.js",
      "node_modules/**",
      "/plugins/**",
      ...
    ],
    "rewrites": [
      {
        "source": "**/**",
        "function": "render"
      }
    ]
  }
}

并创建一个函数render

let app = express();
let config = {
  dev: false
}

const nuxt = new Nuxt(config)
app.use(nuxt.render)

exports.render = functions.https.onRequest(app)

但是,它不起作用,我找不到任何错误。

当我创建一个快速应用程序时,它可以工作。

const config = {
  dev: false
}

const nuxt = new Nuxt(config)

app.use(nuxt.render)

app.listen(3000, ()=>{
  console.log('works')
})

【问题讨论】:

  • 你解决了吗?

标签: google-cloud-functions firebase-hosting server-side-rendering nuxt.js


【解决方案1】:

看来您必须使用以下方法之一终止 http 函数:

response.send()
response.redirect()
response.end()

https://firebase.google.com/docs/functions/http-events#terminate_http_functions

【讨论】:

    猜你喜欢
    • 2020-06-17
    • 2023-04-07
    • 2017-12-11
    • 2020-06-13
    • 2018-11-12
    • 2018-10-31
    • 2018-04-11
    • 2018-07-28
    • 2020-07-18
    相关资源
    最近更新 更多