Skip to content

Commit

Permalink
SHARE-9: Move script injection from nuxt config to layout
Browse files Browse the repository at this point in the history
Injecting the scripts inside the Nuxt config breaks the build of the
application, because the environment variables are not availalble during build
time. This change moves the configuration to the layout file, where the config
is present.
  • Loading branch information
LukasSkywalker committed May 22, 2024
1 parent 52639fc commit c241e36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 8 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export default Vue.extend({
overlay: false
}
},
head() {
return {
script: [
{ src: `${this.$nuxt.context.$config.WEP_API_URL_CLIENT.replace('/v1', '')}/static/head.js` },
{ src: `${this.$nuxt.context.$config.WEP_API_URL_CLIENT.replace('/v1', '')}/static/body.js`, body: true },
]
}
},
computed: {
redirectUrl (): string | undefined {
return this.$nuxt.context.$config.REDIRECT_URL
Expand Down
8 changes: 3 additions & 5 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ export default {
{rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png'},
{rel: 'manifest', href: '/site.webmanifest'},
{rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#000000'}
],
script: [
{ src: `${process.env.WEP_API_URL_CLIENT.replace('/v1', '')}/static/head.js` },
{ src: `${process.env.WEP_API_URL_CLIENT.replace('/v1', '')}/static/body.js`, body: true },
]
},
publicRuntimeConfig: {
Expand Down Expand Up @@ -97,7 +93,9 @@ export default {
// HAS internal
MEDIUM_SLUG: 'HAS'
},
privateRuntimeConfig: {},
privateRuntimeConfig: {
WEP_API_URL_CLIENT: process.env.WEP_API_URL_CLIENT
},

// Global CSS: https://go.nuxtjs.dev/config-css
css: [
Expand Down

0 comments on commit c241e36

Please sign in to comment.