diff --git a/client/store/environment.js b/client/store/environment.js index a88f9c854..f4c56463c 100644 --- a/client/store/environment.js +++ b/client/store/environment.js @@ -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 = {}; diff --git a/client/store/index.js b/client/store/index.js new file mode 100644 index 000000000..d0086f2b1 --- /dev/null +++ b/client/store/index.js @@ -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' + }; + } + } +};