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
| // 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" | |
| } | |
| }; |
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
| 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 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
| /* | |
| 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), |
OlderNewer