Skip to content

Nuxt 3 "Error: Invariant violation: Please load enterprise recaptcha script first" #1464

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

Open
mojabyte opened this issue Nov 29, 2023 · 0 comments
Labels

Comments

@mojabyte
Copy link

Description

The enterprise script doesn't load. Using enterprise: true in Nuxt 3 and calling the execute provided from useChallengeV3 causes this error:

Error: Invariant violation: Please load enterprise recaptcha script first
    at invariant (utils.mjs?v=c6c10ab5:8:11)
    at getEnterpriseRecaptcha (enterprise-helper.mjs?v=c6c10ab5:3:3)
    at Object.execute (proxy.mjs?v=c6c10ab5:28:14)
    at async execute (challenge-v3.mjs?v=c6c10ab5:10:31)

I tried adding the enterprise script manually, and it worked without a problem.

Minimal Reproducible Example

nuxt.config.ts

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      recaptcha: {
        v3SiteKey: 'X',
      },
    },
  },
  recaptcha: {
    enterprise: true,
  },
});

Form.vue

<template>
  <form @submit="onSubmit">
    ...
  </form>
</template>

<script lang="ts" setup>
const { execute } = useChallengeV3('submit');

const onSubmit = async () => {
  const response = await execute();
  console.log(response);
};
</script>

System info

------------------------------
- Operating System: Linux
- Node Version:     v20.9.0
- Nuxt Version:     3.6.5
- Nitro Version:    2.5.2
- Package Manager:  pnpm@8.10.5
- Builder:          vite
- User Config:      app, css, modules, runtimeConfig, content, devtools, gtm, i18n, nitro, postcss, recaptcha, site, sitemap, robots, veeValidate, vite
- Runtime Modules:  @nuxt/content@2.7.0, @nuxtjs/i18n@8.0.0-rc.4, @vee-validate/nuxt@4.9.6, @zadigetvoltaire/nuxt-gtm@0.0.13, nuxt-gtag@0.5.7, nuxt-simple-sitemap@3.2.6, nuxt-simple-robots@3.1.2, vue-recaptcha/nuxt
- Build Modules:    -
------------------------------
@mojabyte mojabyte added the bug label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant