Skip to content

Instantly share code, notes, and snippets.

@wataruoguchi
Created September 26, 2018 05:57
Show Gist options
  • Save wataruoguchi/63497297d337ad125deb5df9684b9286 to your computer and use it in GitHub Desktop.
Save wataruoguchi/63497297d337ad125deb5df9684b9286 to your computer and use it in GitHub Desktop.
const functions = require('firebase-functions')
const express = require('express')
const { Nuxt } = require('nuxt')
const app = express()
const config = {
dev: false,
buildDir: 'nuxt',
build: {
publicPath: '/public/'
}
}
const nuxt = new Nuxt(config)
function handleRequest(req, res) {
res.set('Cache-Control', 'public, max-age=600, s-maxage=1200')
nuxt.renderRoute('/').then(result => {
res.send(result.html)
}).catch(e => {
res.send(e)
})
}
app.get('*', handleRequest)
exports.nuxtApp = functions.https.onRequest(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment