DEV Community

Discussion on: Deploy nuxt on Firebase

Collapse
 
nanythery profile image
Nadine M. Thêry

Just wanted to say a big thank you for taking the time for writing this. It really saved my day.

As I encountered some issues (not related to your tutorial) just wanted to share in case it's helpful for others:

1) Lint Error when deploying the function related to the "then" clause of the promise.
Solution: turn the function code into async/await:

const functions = require('firebase-functions')
const { Nuxt } = require('nuxt')
const express = require('express')

const app = express()

const config = {
  dev: false,
}

const nuxt = new Nuxt(config)

let isReady = false
async function readyPromise() {
  try {
    await nuxt.ready()
  } catch (error) {
    process.exit(1)
  }
}

async function handleRequest(req, res) {
  if (!isReady) {
    await readyPromise()
  }
  res.set('Cache-Control', 'public, max-age=1, s-maxage=1')
  await nuxt.render(req, res)
}

app.get('*', handleRequest)
app.use(handleRequest)
exports.nuxtssr = functions.https.onRequest(app)

Enter fullscreen mode Exit fullscreen mode
  1. Error 500 when already deployed. You can try to debug this error by going to the Firebase Console, to Functions. Click in "Log" and check what the SSR function is throwing. In my case, it was not finding a specific package. I solved it by running "npm install" within the functions directory.