diff --git a/components/ads/Advertisement.vue b/components/ads/Advertisement.vue index 4a98f4e83..f1eb272b8 100644 --- a/components/ads/Advertisement.vue +++ b/components/ads/Advertisement.vue @@ -79,6 +79,7 @@ export default { onSmallScreen: false, windowResizeListenerDebounce: null, ethicalAdLoad: null, + tries: 0, } }, computed: { @@ -119,7 +120,7 @@ export default { this.displayed = true if (process.browser) { this.handleWindowResize() - this.refresh_ad() + this.refresh_ad(true) } }, methods: { @@ -133,14 +134,14 @@ export default { this.format = sizes[this.type] this.displayed = true // Refresh ad - this.refresh_ad() + this.refresh_ad(true) } return } if (this.onSmallScreen === false) { // Reload ad this.onSmallScreen = true - this.refresh_ad() + this.refresh_ad(true) } this.onSmallScreen = true if (this.smallScreen === 'destroy') { @@ -151,15 +152,24 @@ export default { } }, 300) }, - refresh_ad() { + refresh_ad(reset = false) { + if (reset) { + this.tries = 0 + } + if (this.tries >= 3) { + // Too many tries, we stop + return + } if (this.ethical_ads_on) { clearTimeout(this.ethicalAdLoad) this.ethicalAdLoad = setTimeout(() => { - if (typeof window.ethicalads === 'undefined') { + try { + ethicalads.load() + } catch (e) { console.log('EthicalAds are not loaded yet, retrying...') this.refresh_ad() + this.tries++ } - ethicalads.load() }, 100) } }, diff --git a/nuxt.config.js b/nuxt.config.js index 5b9460ae9..cab4d75ee 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -175,7 +175,7 @@ export default { }, publicRuntimeConfig: { axios: { - browserBaseURL: process.env.BROWSER_BASE_URL, + baseURL: process.env.API_URL, }, ads: { ghostMode: process.env.ENABLE_ADS == null, @@ -187,11 +187,6 @@ export default { base_url: process.env.ARIADNE_URL, }, }, - privateRuntimeConfig: { - axios: { - baseURL: process.env.BASE_URL, - }, - }, } function getDomain() {