Skip to content

Commit

Permalink
feat: add env based server config to nuxt.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fpdrozd committed Mar 20, 2023
1 parent 1917d79 commit 515ce7e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/theme/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import * as dotenv from 'dotenv';

dotenv.config({ path: `./../../.env.${process.env.NODE_ENV}` });

const serverConfig = {
port: process.env.PORT || 3000,
host: process.env.HOST || '0.0.0.0',
baseUrl: process.env.BASE_URL || 'http://localhost:3000'
};

export default {
ssr: true,
server: {
port: process.env.PORT || 3000,
host: process.env.HOST || '0.0.0.0'
port: serverConfig.port,
host: serverConfig.host
},
head: {
title: 'Vue Storefront',
Expand Down Expand Up @@ -96,7 +102,7 @@ export default {
}
}],
['nuxt-i18n', {
baseUrl: process.env.BASE_URL || 'http://localhost:3000'
baseUrl: serverConfig.baseUrl
}],
'cookie-universal-nuxt',
'vue-scrollto/nuxt',
Expand Down Expand Up @@ -190,6 +196,6 @@ export default {
{ code: 'EUR', label: 'Euro' }
],
backendUrl: process.env.BACKEND_URL,
middlewareUrl: 'http://localhost:3000/api/'
middlewareUrl: new URL('/api', serverConfig.baseUrl).href
}
};

0 comments on commit 515ce7e

Please sign in to comment.