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 authors = [ | |
{ id: 1, firstName: "Tom", lastName: "Coleman" }, | |
{ id: 2, firstName: "Sashko", lastName: "Stubailo" } | |
] | |
const posts = [ | |
{ id: 1, authorId: 1, title: "Introduction to GraphQL", votes: 2 }, | |
{ id: 2, authorId: 2, title: "GraphQL Rocks", votes: 3 }, | |
{ id: 3, authorId: 2, title: "Advanced GraphQL", votes: 1 } | |
] |
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 functions = require("firebase-functions") | |
const cors = require("cors") | |
const express = require("express") | |
/* Express with CORS */ | |
const app2 = express() | |
app2.use(cors({ origin: true })) | |
app2.get("*", (request, response) => { | |
response.send("Hello from Express on Firebase with CORS!") | |
}) |
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 functions = require("firebase-functions") | |
const cors = require("cors") | |
const express = require("express") | |
/* Express with CORS & automatic trailing '/' solution */ | |
const app3 = express() | |
app3.use(cors({ origin: true })) | |
app3.get("*", (request, response) => { | |
response.send( | |
"Hello from Express on Firebase with CORS! No trailing '/' required!" |
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
# src/app/.gitignore | |
.next |
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
{ | |
"hosting": { | |
"public": "src/public" | |
}, | |
"functions": { | |
"source": "src/functions" | |
} | |
} |
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
{ | |
"projects": { | |
"default": "this will be the name you gave to the firebase project you linked" | |
} | |
} |
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
# src/functions/.gitignore | |
next |
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 functions = require("firebase-functions") | |
const next = require("next") | |
var dev = process.env.NODE_ENV !== "production" | |
var app = next({ dev, conf: { distDir: "next" } }) | |
var handle = app.getRequestHandler() | |
exports.next = functions.https.onRequest((req, res) => { | |
console.log("File: " + req.originalUrl) // log the page.js file that is being requested | |
return app.prepare().then(() => handle(req, res)) |
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
{ | |
"name": "nextonfirebase", | |
"version": "1.0.0", | |
"license": "MIT", | |
"scripts": { | |
"install": "yarn build-all", | |
"next": "yarn build-firebase && cd \"src/app\" && yarn && yarn dev", | |
"preserve": "yarn build-all", | |
"serve": "firebase serve", | |
"predeploy": "yarn build-all", |
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
{ | |
"hosting": { | |
"public": "src/public", | |
"rewrites": [ | |
{ | |
"source": "**/**", | |
"function": "next" | |
} | |
] | |
}, |