Created
September 26, 2018 05:57
-
-
Save wataruoguchi/63497297d337ad125deb5df9684b9286 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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