Skip to content

Instantly share code, notes, and snippets.

View jacobedawson's full-sized avatar
🎯
JS Ecosystem Explorer

Jacob E. Dawson jacobedawson

🎯
JS Ecosystem Explorer
View GitHub Profile
@jacobedawson
jacobedawson / next.config.js
Last active July 7, 2019 15:37
Next Config for Environment Variables
// Create the next.config.js file in your root dir
module.exports = {
env: {
API:
process.env.NODE_ENV === "production"
? process.env.API_URL
: "http://localhost:8080/api"
}
};
@jacobedawson
jacobedawson / example.js
Last active July 7, 2019 15:36
Using the process.env variable in Next.js
import axios from "axios";
Example.getInitialProps = async () => {
try {
const data = await axios.get(process.env.API);
// do something with data...
} catch (err) {
console.log(err):
}
}
/*
This middleware accesses the firebase id token in the request header.
Then we use the Firebase Admin SDK to verify the token.
If successful we pass the route on, otherwise we return an error
*/
const admin = require("firebase-admin");
const serviceAccount = require("../config/firebase-account.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),