Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Next public env vars #1006

Merged
merged 2 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/Billing.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ const BillingWithStripe = injectStripe(Billing)
export default function () {
const [stripe, setStripe] = React.useState(null)
React.useEffect(() => {
setStripe(window.Stripe(process.env.STRIPE_PUBLIC_KEY))
setStripe(window.Stripe(process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY))
}, [])
return (
<StripeProvider stripe={stripe}>
Expand Down
2 changes: 1 addition & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import firebase from './client'
import { DEFAULT_CODE, DEFAULT_SETTINGS } from './constants'

export const client = axios.create({
baseURL: `${process.env.API_URL || ''}/api`,
baseURL: `${process.env.NEXT_PUBLIC_API_URL || ''}/api`,
headers: {
Accept: 'application/json',
},
Expand Down
16 changes: 8 additions & 8 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import * as firebase from 'firebase/app'
import 'firebase/auth'

if (firebase.apps.length === 0) {
if (process.env.FIREBASE_API_KEY && process.env.FIREBASE_FE_APP_ID) {
if (process.env.NEXT_PUBLIC_FIREBASE_API_KEY && process.env.NEXT_PUBLIC_FIREBASE_FE_APP_ID) {
firebase.initializeApp({
apiKey: process.env.FIREBASE_API_KEY,
authDomain: `${process.env.FIREBASE_PROJECT_ID}.firebaseapp.com`,
databaseURL: `https://${process.env.FIREBASE_PROJECT_ID}.firebaseio.com`,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: `${process.env.FIREBASE_PROJECT_ID}.appspot.com`,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_FE_APP_ID,
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.firebaseapp.com`,
databaseURL: `https://${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.firebaseio.com`,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: `${process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID}.appspot.com`,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_FE_APP_ID,
})
}
}
Expand Down
45 changes: 19 additions & 26 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
const bundleAnalyzer = require('@next/bundle-analyzer')
const withOffline = require('next-offline')

const withBundleAnalyzer = bundleAnalyzer({ enabled: true })
const withBundleAnalyzer = bundleAnalyzer({ enabled: process.env.ANALYZE === 'true' })

const config = withOffline({
target: 'serverless',
dontAutoRegisterSw: true,
// https://github.com/hanford/next-offline/blob/master/packages/now2-example/next.config.js
workboxOpts: {
swDest: 'static/service-worker.js',
},
env: {
FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID,
FIREBASE_MESSAGING_SENDER_ID: process.env.FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_FE_APP_ID: process.env.FIREBASE_FE_APP_ID,
FIREBASE_API_KEY: process.env.FIREBASE_API_KEY,
STRIPE_PUBLIC_KEY: process.env.STRIPE_PUBLIC_KEY,
},
webpack: (config, options) => {
config.module.rules.push({
test: /\.js$/,
include: /node_modules\/graphql-language-service-parser/,
use: [options.defaultLoaders.babel],
})
module.exports = withBundleAnalyzer(
withOffline({
target: 'serverless',
dontAutoRegisterSw: true,
// https://github.com/hanford/next-offline/blob/master/packages/now2-example/next.config.js
workboxOpts: {
swDest: 'static/service-worker.js',
},
webpack: (config, options) => {
config.module.rules.push({
test: /\.js$/,
include: /node_modules\/graphql-language-service-parser/,
use: [options.defaultLoaders.babel],
})

return config
},
})

module.exports = process.env.ANALYZE === 'true' ? withBundleAnalyzer(config) : config
return config
},
})
)
10 changes: 0 additions & 10 deletions now.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@
},
{ "handle": "filesystem" }
],
"build": {
"env": {
"NODE_ENV": "production",
"FIREBASE_PROJECT_ID": "@carbon-firebase-project-id",
"FIREBASE_MESSAGING_SENDER_ID": "@carbon-firebase-messaging-sender-id",
"FIREBASE_FE_APP_ID": "@carbon-firebase-fe-app-id",
"FIREBASE_API_KEY": "@carbon-firebase-api-key",
"STRIPE_PUBLIC_KEY": "@carbon-stripe-public-key"
}
},
"github": {
"autoAlias": false,
"silent": true
Expand Down