Last active
May 25, 2020 03:09
-
-
Save jthegedus/64cd5e233b8870349580930bff5e327a to your computer and use it in GitHub Desktop.
Next.js on Cloud Functions for Firebase
This file contains 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 admin = require("firebase-admin"); | |
const functions = require("firebase-functions"); | |
const next = require("next"); | |
const config = require("./next.config"); | |
admin.initializeApp(); | |
const dev = process.env.NODE_ENV !== "production"; | |
const app = next({ | |
dev, | |
// the absolute directory from the package.json file that initialises this module | |
// IE: the absolute path from the root of the Cloud Function | |
conf: config, | |
}); | |
const handle = app.getRequestHandler(); | |
const server = functions.https.onRequest((request, response) => { | |
// log the page.js file or resource being requested | |
console.log("File: " + request.originalUrl); | |
return app.prepare().then(() => handle(request, response)); | |
}); | |
exports.nextjs = { server }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment