Open zumm opened 1 year ago
I faced the same issue.
I solved this issue by removing google-adsence
public runtime config.
In my case, I don't useGOOGLE_ADSENSE_ID
variable itself in our components, we just need <adsbygoogle>
components, that's why I could delete its runtime config.
What I needed to do was to define id
and test
options inside @nuxtjs/google-adsense
options.
(I need to define GOOGLE_ADSENSE_ID
and GOOGLE_ADSENSE_TEST_MODE
environment vars before running nuxt build
.)
modules: [
[
'@nuxtjs/google-adsense',
{
id: process.env.GOOGLE_ADSENSE_ID,
test: process.env.GOOGLE_ADSENSE_TEST_MODE === 'true',
onPageLoad: false,
pageLevelAds: false,
},
],
Blow is my blog nuxt3 application that uses this module. https://github.com/kumanote/tech-blog-web/pull/3/files#diff-5977891bf10802cdd3cde62f0355105a1662e65b02ae4fb404a27bb0f5f53a07R252
Contributions welcome!
At this moment this is impossible to use runtime config with this module in latest versions of nuxt. The problem is only variables defined in
public
section accessible on client side. See docs. So sectiongoogle-adsence
should be moved intopublic
.Also camelCase should be preferred for section naming. So
google-adsence
should be renamed togoogleAdsense
.UPD: Moreover module does nothing, but prints warn "Invalid AdSense client ID specified" if option
id
is not specify directly through module options.