Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime config is broken #173

Open
zumm opened this issue Jan 14, 2023 · 2 comments
Open

Runtime config is broken #173

zumm opened this issue Jan 14, 2023 · 2 comments

Comments

@zumm
Copy link

zumm commented Jan 14, 2023

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 section google-adsence should be moved into public.

Also camelCase should be preferred for section naming. So google-adsence should be renamed to googleAdsense.

UPD: Moreover module does nothing, but prints warn "Invalid AdSense client ID specified" if option id is not specify directly through module options.

@KumanoTanaka
Copy link

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

@TheAlexLichter
Copy link
Collaborator

Contributions welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants