Skip to content

Commit

Permalink
🐛 fix environment variables with nuxtServerInit
Browse files Browse the repository at this point in the history
  • Loading branch information
moisout committed Sep 18, 2020
1 parent daf2818 commit f016d1e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 2 additions & 6 deletions client/store/environment.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
export const state = () => ({
apiUrl: process.env.apiUrl,
vapidKey: process.env.vapidKey,
nodeEnv: process.env.NODE_ENV
env: {}
});
export const getters = {
apiUrl(state) {
return state.apiUrl;
return state.env.apiUrl;
}
};
export const mutations = {};
export const actions = {};
14 changes: 14 additions & 0 deletions client/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const actions = {
nuxtServerInit({ rootState }) {
if (process.server) {
rootState.environment.env = {
apiUrl: process.env.VIEWTUBE_API_URL,
vapidKey: process.env.VIEWTUBE_PUBLIC_VAPID,
nodeEnv: process.env.NODE_ENV,
host: process.env.HOST || 'localhost',
port: process.env.PORT || 8066,
baseUrl: process.env.BASE_URL || 'http://localhost:8066'
};
}
}
};

0 comments on commit f016d1e

Please sign in to comment.