Code Monkey home page Code Monkey logo

recaptcha-module's Introduction

Google reCAPTCHA

npm version npm downloads Circle CI Codecov Standard JS

๐Ÿค– Simple and easy Google reCAPTCHA integration with Nuxt.js

๐Ÿ“– Release Notes

Setup

  1. Add @nuxtjs/recaptcha dependency with yarn or npm into your project
  2. Add @nuxtjs/recaptcha to modules section of nuxt.config.js
  3. Configure it:
{
  modules: [
    [
      '@nuxtjs/recaptcha', {
        /* reCAPTCHA options */
      }
    ],
  ]
}

using top level options

{
  modules: [
    '@nuxtjs/recaptcha',
  ],

  recaptcha: {
    /* reCAPTCHA options */
  },
}

Configuration

{
  // ...
  recaptcha: {
    hideBadge: Boolean, // Hide badge element (v3 & v2 via size=invisible)
    language: String,   // Recaptcha language (v2)
    mode: String,       // Mode: 'base', 'enterprise'
    siteKey: String,    // Site key for requests
    version: Number,    // Version
    size: String        // Size: 'compact', 'normal', 'invisible' (v2)
  },
  // ...
}

Runtime config

// nuxt.config.js
export default {
  publicRuntimeConfig: {
    recaptcha: {
      /* reCAPTCHA options */
      siteKey: process.env.RECAPTCHA_SITE_KEY // for example
    }
  }
}

Generate reCAPTCHA Site Keys

You can generate keys for the basic mode by registering a new site.

For the enterprise mode, use the Google Cloud Console.

Usage

reCAPTCHA v2

  1. Add <recaptcha> component inside your form:
<form @submit.prevent="onSubmit">
  <input autocomplete="true" placeholder="Email" type="email" v-model="email">
  <input autocomplete="current-password" placeholder="Password" type="password" v-model="password">
  <recaptcha />
  <button type="submit">Sign In</button>
</form>
  1. Call getResponse inside form submit handler to get reCAPTCHA token:
async onSubmit() {
  try {
    const token = await this.$recaptcha.getResponse()
    console.log('ReCaptcha token:', token)

    // send token to server alongside your form data

    // at the end you need to reset recaptcha
    await this.$recaptcha.reset()
  } catch (error) {
    console.log('Login error:', error)
  }
},

See:

reCAPTCHA v3

  1. Call init function inside mounted hook of your page
async mounted() {
  try {
    await this.$recaptcha.init()
  } catch (e) {
    console.error(e);
  }
}
  1. Call execute function form submit handler to get reCAPTCHA token:
async onSubmit() {
  try {
    const token = await this.$recaptcha.execute('login')
    console.log('ReCaptcha token:', token)

    // send token to server alongside your form data

  } catch (error) {
    console.log('Login error:', error)
  }
}
  1. Call destroy function inside beforeDestroy hook of the page. (This will remove reCAPTCHA scripts, styles and badge from the page)
beforeDestroy() {
  this.$recaptcha.destroy()
}

See:

Server Side

When you send data + token to the server, you should verify the token on the server side to make sure it does not requested from a bot. You can find out how to verify token on the server side by looking at the server middleware inside v2 example. (The server side is same for both versions)

Info Hiding Badges

You're allowed to hide the badge (i.e. for v3 and v2 invisible), as long as you include the recaptcha branding in the user flow.

For example:

<small>This site is protected by reCAPTCHA and the Google
    <a href="https://policies.google.com/privacy">Privacy Policy</a> and
    <a href="https://policies.google.com/terms">Terms of Service</a> apply.
</small>

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

Copyright (c) mvrlin [email protected]

recaptcha-module's People

Contributors

abakermi avatar andrewmurraydavid avatar atinux avatar bason8800 avatar dependabot[bot] avatar dexapiens avatar farnabaz avatar lat1992 avatar lecoupa avatar mvrlin avatar owalid avatar owenandrews avatar p4sca1 avatar randompch avatar redbayoub avatar sgarner avatar thepoon avatar therealwolf42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

recaptcha-module's Issues

*** recaptcha won't show up if re-visit the same page.

hi community,

The recaptcha-module has an issue, "recaptcha won't show up if re-visit the same page". My app is an universal application, route from landing page to the page with recaptcha it shows, and then route to landing page and go back to the page with recapcha, but the recapcha won't shown up.
I have to refresh the page then it shows.

Even I tried to code only the component in the template, still same happens, like this:

      <template>
           <div>
          <recaptcha />
        </div>
       </template>

Please help!!

this is my settings in nuxt.config.js

['@nuxtjs/recaptcha', {
      hideBadge: false,
      siteKey: process.env.CAPTCHA_SITE_KEY, 
      version: 2,
    }],

I'm using the latest version of the recapcha-module v0.3.3.

There was a problem initializing recaptcha/api.js on v3

I'm using V3 key๏ผŒWhen I started the project and looked at the loaded recaptcha/api.js, I found that the JS was missing the render parameter value, and then I printed the value in the dependency and found that in the init method, this. siteKey was valuable, but There is no value after using the string template
Init method in plugin. JS in source code๏ผš
`
init () {

console.log(this.siteKey) 

console.log(src.concat(`?render=${this.siteKey}`))

......
scriptElement.setAttribute('src', this.version === 2 ? src : src.concat(`?render=${this.siteKey}`))
.....

`

Print the result after project start as follows๏ผš
6Ldyo6AUAAA......
https://www.google.com/recaptcha/api.js?render=

Q:Is this because my project does not support es6? But I have no problem writing this string template in my own project, or do I need to configure something extra to support your third-party package as well as string template?

error message: "Error message to website owners: Invalid key type"

just updated the package from 1.0.2 to 1.0.3, the above error appeared, this is the setting:

(nuxt.config.js)
modules: [
'@nuxtjs/axios',
'@nuxtjs/device',
'@nuxtjs/recaptcha'....
],
recaptcha: {
hideBadge: false,
siteKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
version: 3,
size: 'invisible'
},

component usage is like:
<recaptcha />

will wait for the fix. ๐Ÿ‘

Error: Could not compile template

Hello. I`m using "nuxt": "^1.4.0", and after install the package I have this error in my project
ERROR
Error: Could not compile template .
...\node_modules@nuxtjs\recaptcha\lib\plugin.js: error is not defined

  • builder.js:471 Promise.all.templatesFiles.map
    [....]/[nuxt]/lib/builder/builder.js:471:17

reset() multiple component

i'm using 2 recaptcha component inside login form and otp modal,
but i can't reset recaptcha inside my modal, but its keep reseting recaptcha component in login form.

if i'm just use 1 recaptcha component inside modal and remove recaptcha in login form, reset() is work to reset my recaptcha inside modal.

is that possible to using more than 1 recaptcha component in one page? and reset multiple of it or specifically?

Need to set the timeout option on request

Hi all,

I want to set a timeout on my request to google, because maybe a user will have a very poor network and i want to get an error message after x seconds and not I cannot do it now. I have to wait until the request is completed or fails.

Is there any other way to do from nuxt ?

Thanks

Nuxt: v.2.15.3
recaptcha module: v1.0.2

Recaptcha doesn't show up unless page is refreshed (F5)

Using version 0.6.2, my Recaptcha v2 doesn't appear unless I navigate directly to the page or refresh after navigating to the page. Might be related to #12. I tried calling this.$recaptcha.reset() on mount but that didn't have any effect.

Remove captcha properly while navigating

After validating a form and passing the captcha, the iframe from google (bottom right corner) does not disappear.

Navigating on pages which does not contain the captcha should not display this iframe.

I tried to remove it manually in the beforeDestroyfrom my nuxt page component :

  beforeDestroy() {
    //remove initiated recaptcha
    let recap = document.querySelector(".grecaptcha-badge")
    recap.parentNode.removeChild(recap)
  }

But then it does not reload when I navigate to a page supposed to contain the captcha

I think this behavior should be handled.

How to reset the recaptcha after form reset?

I am using recaptcha v2.
Once the form is being submitted after successful recaptcha, i need to reset the recaptcha
Since i am on the same page.
So how can i obtain it?
I have tried with
this.$recaptcha.init()
but doesnot work
Screen Shot 2019-10-20 at 13 58 53

No guide on how to use recaptcha-module

the README only specifies how to install and configure recaptcha-module in our nuxt project. How do I use it in my project to validate that client signing is human and not a bot?

Version 3 should support language key

Configuration and code states that language is only supported in v2.

language: String,   // Recaptcha language (v2)

However, it should be supported in v3 because google does. Basically ?hl works in v3 too.

this.$recaptcha.reset is not a function

I'm trying to reset the captcha when the user clicks on a button by running the this.$recaptcha.reset();
In my local project it works as expected but once I test it in deployment server it gives me the following error:
Screenshot 2020-02-28 at 11 48 04 AM

document is not defined error

<v-input :error-messages="recaptchaErrors">
          <no-ssr>
            <recaptcha @error="onError" />
          </no-ssr>
        </v-input>

Hello. I'm using recaptcha in form and it works good.

but, document is not defined error occured when I refresh the page or I connect directly the path.

no-ssr component is not working.

function(req, res, next) {
  const paths = ['/recaptcha-form-path']
  if (paths.includes(req.originalUrl)) res.spa = true
  next()
}

so, I tried to render no ssr mode with server middleware, then It works. but often there's need ssr.

how can I use recaptcha module with pages that need ssr?

thanks.

Add more than one module on the same page

Hi! Great component.

I have successfully implemented it, but now I am asked to implement it in another form that is in the same page. The moment I add the second reCAPTCHA I can't send the forms, I get an error.

Is it possible to have more than one reCAPTCHA with this component??

Thank you in advance!

reCAPTCHA v2 refresh the page and my form data are erased ?

Hi everybody.

I have a form with many fields and my reCAPTCHA at the bottom of the page.
I put all informations in every fields and when I click on the reCAPTCHA at the bottom of the page, all the form is erased.
All data stored in the vuex store are still there, but all fields on the screen are empty ?

Can someone help me please ?

Thx a lot.

Manually initialize ReCaptcha Module with dynamic siteKey?

Hi, thanks for this awesome library,

I have been using this package for a while with no issues.

Recently I developed a project where I need the ability to:
1.) Manually initialize ReCaptcha siteKey

Basically, I want to be able to change the ReCaptcha site key after running "npm run build" using a dynamic Google ReCaptcha siteKey based on/provided by the client own deployment of the app (ps: they cannot edit nuxt.config.js and rebuild project that's why I really need this solution).

A similar option is currently available with @nuxtjs/gtm

Where we can do the following:

nuxt.config.js

export default { modules: [ '@nuxtjs/gtm' ], plugins: [ '~/plugins/gtm' ] }

plugins/gtm.js:

export default function({ $gtm, route }) { $gtm.init('GTM-XXXXXXX') }

Could a similar option like this please be added to this module? Seems like it shouldn't be very complicated to add!!!

Please any guidance or assistance on how to achieve this with this module would be greatly appreciated.

Thanks so much in advance!

'_isDestroyed' of undefined on page refresh

I have created a static site using nuxt generate command and the site is hosted on ASW S3. On page refresh I am getting below error though it works fine in the local machine.

vue.runtime.esm.js:1888 TypeError: Cannot read property '_isDestroyed' of undefined at destroy (vue.runtime.esm.js:3157) at E (vue.runtime.esm.js:6114) at E (vue.runtime.esm.js:6119) at E (vue.runtime.esm.js:6119) at f.__patch__ (vue.runtime.esm.js:6467) at f.t.$destroy (vue.runtime.esm.js:4001) at destroy (vue.runtime.esm.js:3159) at E (vue.runtime.esm.js:6114) at E (vue.runtime.esm.js:6119) at f.__patch__ (vue.runtime.esm.js:6467)

ReCaptcha error: Failed to execute

when I use reCaptcha in asyncData,it was given an error๏ผšFailed to execute ๏ผ›
can I use reCaptcha in asyncData๏ผŸBecause some interface runs in asyncDataใ€‚

ReCaptcha error: Failed to load script

Hi, I am trying the plugin but when the page loads the mounted function it shows the next issue:

"ReCaptcha error: Failed to load script at HTMLScriptElement."

Do you know the issue?

Thanks in advance.

Regards,
Arsenio

Why reset() is only possible in version 2

In version 3 I have to use window.recaptcha.reset(); instead of this.$recaptcha.reset.
In the code we can see that:
in the reset function the window.grecaptcha.reset(); is only possible in version 2. Is there a reason ?

  reset () {
    if (this.version === 2) {
      window.grecaptcha.reset()
    }
  }

could we write that instead?

  reset () {
    if (this.version === 2 || this.version === 3) {
      window.grecaptcha.reset()
    }
  }

Invalid action name

After a suscessful installation of the recaptcha (v3), I tried to execute an action just like this:

this.$recaptcha.execute(process.env.NUXT_ENV_RECAPTCHA, { action: 'homepage' });

Which gave me the following error:

recaptcha__en.js:514 Invalid action name, may only include โ€œA-Za-z/_โ€. Do not include user-specific information.

I could make a workaround by (mounted method):

await this.$recaptcha.init();

window.grecaptcha.ready(() => {
  window.grecaptcha.execute(process.env.NUXT_ENV_RECAPTCHA, { action: 'homepage' });
});

or

await this.$recaptcha.init();
await this.$recaptcha._ready;
window.grecaptcha.execute(process.env.NUXT_ENV_RECAPTCHA, { action: 'homepage' });

Fatal Error

After installing and configuring the module, I got the below error on

yarn run dev or yarn run build

Nuxt v2.6.3

FATAL The 'request' argument must be string. Received type undefined 20:57:54
at node_modules/esm/esm.js:1:220358
at Module. (node_modules/esm/esm.js:1:289859)
at Resolver.n [as esm] (node_modules/esm/esm.js:1:273820)
at Resolver.requireModule (node_modules/@nuxt/core/dist/core.js:624:31)
at ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:164:36)
at promise.then (node_modules/@nuxt/utils/dist/utils.js:1790:43)

dataSize invalid prop error

Hi, i've installed the latest version 0.5.0 that added invisible option, but Vue still throws invalid prop error when passing invisible as the value.

DOMException

Hi,

Everything is working fine except this error:
image

I've the same error locally and on Firebase hosting.

I've try to add those config in the nuxt.config.js for setting up the headers but it change nothing.
image
image

Somebody know what I'm missing?

Thank you!

ReCaptcha error: Failed to execute

I get this error everytime.. How to fix this?

I am using v3..

Is there no component to put on the view? There is one on the example on v2, but nothing for v3 neither in the docs too.. Seems wrong..

Async defer recaptcha script

currently the evaluation of recaptcha.js takes a bit long and affects the page speed perfomance it will be much better if we could defer evaluation of the recaptcha script

Handling two recaptchas on same page

I'm having problems finding a solution for two recaptchas that are in two different components in the same page and have different methods runnig for their emitted onSuccess events.

If I run this.$recaptcha.getResponse() on any of them because of a form submit the onSuccess emitted event will run both of the AJAX in both of the components.

I tried using ref in each one of them, but I can't find a way to run the getResponse() so I dont have to call this.$recaptcha.getResponse() and instead call it like this.$refs.componentOneRecaptcha.getResponse() but it wont run at that level because there's no getResponse(). Is there any other smarter way to do this?

v2 callback?

hi is there a way to have a callback when the captcha is solved?

await this.$recaptcha.execute method returning null

Hey there, I'm not sure if this module is even production ready or not but I was playing with it and can't seem to get the captcha response to return anything. I see that it's calling the underlying window.grecaptcha.execute method, but it's not doing anything else past that.

I'm in a mostly freshly generated nuxt.js project (generated via official npx) and pretty much copy/pasted the example code in.

Since this module is marked "WIP", does that mean this functionality just isn't here yet?

Thanks!

SameSite warning from chrome

When I tried to run $recaptcha.init(), this make SameSite warning on the local dev environment.
How to solve it?

Enable use for ReCaptcha enterprise

The changes needed to be made are the following:

  • Make the script URL configurable. The enterprise script is located here: https://www.google.com/recaptcha/enterprise.js?render=reCAPTCHA_site_key
  • Make the calls to the enterprise grecaptcha API instead:
grecaptcha.enterprise.ready(function() {
      grecaptcha.enterprise.execute('reCAPTCHA_site_key', {action: 'homepage'}).then(function(token) {
       ...
    });
});

More documentation about this Google Cloud feature.

Serializing native function: Boolean

Having an issue running this with typescript in spa mode that I cannot even start it with default options.

Maybe having an error compiling this

 inject('recaptcha', new ReCaptcha(<%= serialize(options) %>))

Only renders once

Trying to use the recaptcha v2 component in parallel (I have a login, register and reset password forms that I use it for, however it will render only for one of the forms (the login). All of these forms exist on the dom at the same time. The methods also seem universal, in that they're not encapsulated to that instance of the component, so calling reset on one component will reset all the components.

An example being that vue-recaptcha are encapsulated, don't share state or methods and I can hook into them directly through this.$refs.

How to actually use the captcha on a page?

Documentation is great for setting up, but how do I actually use the recaptcha on a given page? After seting it up, I'm intercepting the request params but there's no captcha params at all.

Captcha renders only once (v2)

Hi i have a problem ^^

this is a component inside my page register.vue

<template>
  <form-wrapper
    action="auth/register"
    @submit.prevent="register">
    <div class="row">
      <div class="col">
        <text-field
          v-model="formData.name"
          v-validate="`required`"
          name="name"
          :errors="errors.collect('name')"
          label="First Name"
          type="text" />
      </div>
      <div class="col">
        <text-field
          v-model="formData.lastname"
          v-validate="`required`"
          name="lastname"
          :errors="errors.collect('lastname')"
          label="Last Name"
          type="text" />
      </div>
    </div>

    <text-field
      v-model="formData.email"
      v-validate="`required|email`"
      name="email"
      :errors="errors.collect('email')"
      label="Email"
      type="email" />

    <div class="row">
      <div class="col">
        <text-field
          ref="password"
          v-model="formData.password"
          v-validate="{required:true, regex:passwordRegex}"
          name="password"
          :errors="errors.collect('password')"
          label="Password"
          type="password">
          <template v-slot:help>
            The password must have at least 1 uppercase Letter,
            1 lowercase Letter
            1 digit,
            1 symbol,
            a minimum of 7 letters
          </template>
        </text-field>
      </div>
      <div class="col">
        <text-field
          v-model="formData.password_repeat"
          v-validate="{regex:passwordRegex, confirmed:'password'}"
          name="password_repeat"
          :errors="errors.collect('password_repeat')"
          label="Confirm Password"

          type="password" />
      </div>
    </div>

    <div class="captcha">
      <recaptcha />
      <text-field
        v-model="formData.captcha_token"
        v-validate="`required`"
        name="captcha_token"
        :errors="errors.collect('captcha_token')"
        type="hidden" />
    </div>
    <button
      class="button button--dark"
      type="submit">
      Register
    </button>
  </form-wrapper>
</template>

<script>
// Todo: add Terms
  import FormWrapper from '@/components/Forms/FormWrapper'
  import TextField from '@/components/FormFields/TextField'
  export default {
    $_veeValidate: {
      validator: 'new' // give me my own validator scope.
    },
    name: 'RegisterForm',

    components: {
      FormWrapper,
      TextField
    },

    data () {
      return {
        formData: {
          email: '',
          lastname: '',
          name: '',
          password_repeat: '',
          password: '',
          terms_checked: false,
          captcha_token: ''
        },
        passwordRegex: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{7,})/
      }
    },

    methods: {
      async register () {
        try {
          const token = await this.$recaptcha.getResponse()
          this.formData.captcha_token = token
        } catch (error) {}

        try {
          const res = await this.$axios.post('/user/register', this.formData)
        } catch (err) {
          const statusCode = err.response.status
          if (statusCode === 422) {
            this.$setLaravelValidationErrorsFromResponse(err.response.data)
            // eslint-disable-next-line no-undef
            grecaptcha.reset()
          }
        }
      }
    }
  }
</script>

when i come from a other route it does not load the captcha.

So i start on /register wehere the captcha is then i go to login and i go back to register captch does not load again

it works when i hit f5 on /login and then i go to /register but only once :D

i have no idea whats wrong thanks

//e i alos tested to put <recaptcha /> direct in the page same behavior

Lack of documention

No information on how to use this with v2 invisible.

Useless devs making packages everywhere...

Closing the documentation gap

Hey y'all, have implemented this a couple of times, but not often enough that I remember everything off the top of my head. Thought I'd try to contribute a couple code snippets that I use for reference to help others who are looking to use this module. Wasn't sure if this would warrant a pull request or not. If I'm dropping this in the wrong spot my apologies.

After installing the module and adding a config in nuxt.config.js following the existing docs, I set up a serverMiddleware to handle sending the recaptcha token along to the recaptcha service with the secret sitekey, without exposing it to the client (though I've ended up exposing my sitekey in commits more than once, ha).

In nuxt.config.js:

  serverMiddleware: ['~/api/recaptchaAuth'],

  ...

    modules: [ '@nuxtjs/recaptcha'],

  ...

  recaptcha: {
    hideBadge: true, // Hide badge element (v3 & v2 via size=invisible)
    siteKey: 'YOUR_SITEKEY', // Site key for requests
    version: 3, // Version, I like 3 because it's invisible ๐Ÿ‘พ 
  },

In ~/api/recaptchaAuth:

const app = require('express')()
const cors = require('cors')
const bodyParser = require('body-parser')
import axios from 'axios' // I want to use @nuxtjs/axios here but not savvy enough to figure out how to import ๐Ÿคทโ€โ™‚๏ธ 

const SECRET_KEY = 'YOUR_SECRET_KEY_HERE'

app.use([bodyParser.json(), cors()])
// I allowed cors here so I could test from 127.0.0.1 
// in addition to localhost, but you may want to remove 
// this before publishing your app/site.
app.options('*', cors()) 

app.post('/recaptcha', async (req, res) => {
  try {
    const { host } = req.headers
    const { token } = req.body

    if (!token) {
      res.status(400).send('No token!')
      throw 'No token!'
    }

    const { data } = await axios.post(
      `https://www.google.com/recaptcha/api/siteverify?secret=${SECRET_KEY}&response=${token}`,
    )

    res.send(data)
  } catch (e) {
    console.log('ReCaptcha error:', e)
    res.status(500).send(`<p>ReCaptcha error:</p> <pre>${e}</pre>`)
  }
})

module.exports = app

In the component/page where you want to use recaptcha, add a method (in this example, ~/components/nav.vue, to hide and show contact info):

  methods: {
    async show() {
      try {
        const token = await this.$recaptcha.execute('contact') //my action is named contact but this can be whatever
        const res = await this.$axios.$post('/recaptcha', { token })

        if (res.success === true) this.$modal.show('contact-modal')
        else throw new Error('looks like you might not be a human :(')
      } catch (e) {
        console.log('Error:', e)
      }
    },
  },

And to complete my V3 example, I need to include the disclaimer:

  <p class="disclaimer">
    This site is protected by reCAPTCHA and the Google
    <a href="https://policies.google.com/privacy">Privacy Policy</a>
    and
    <a href="https://policies.google.com/terms">Terms of Service</a>
    apply.
  </p>

Nuxt Build Error

I got an error

Property '$recaptcha' does not exist on type 'Page'.

I have done adding dependencies and add it to modules at nuxt.config.ts
package.json

...
"dependencies": {
    ...
    "@nuxtjs/recaptcha": "^0.4.1",
    ...
},
...

nuxt.config.ts

   ...
   modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
    '@nuxtjs/recaptcha',
  ],
  recaptcha: {
    hideBadge: process.env.NODE_ENV !== 'development',
    siteKey: <MY_SITE_KEY>,
    version: 3
  },
  ...

and what I have been doing in the Page is something like this

async mounted() {
    await this.$recaptcha.init();
}

async submitForm() {
    try {
      const token = await this.$recaptcha.execute('login');
    } catch (error) {
      console.error(error)
    }
}

And I got error in those lines with $recaptcha when I ran nuxt build. I am using @nuxt/cli v2.6.1
. Plus, in development mode, it runs perfectly. Can you please help?

API_URL is missing when compile template.

I got an error like this.

Error: Could not compile template /MyProject/node_modules/@nuxtjs/recaptcha/lib/plugin.js: API_URL is not defined

But it can be fix like this.

if (this.version === 2) {
  script.setAttribute('src', API_URL + '?hl=' + this.language)
} else {
  script.setAttribute('src', API_URL + '?render=' + this.siteKey)
}

captcha not adjusting for media screens

The image selector is not consistent in its placement on mobile screens. Sometimes it adjust itself and its perfectly centered, sometimes the image selector pops out to the right so that half of the images are unreachable.

It seems that issue is in the inline styling of the captcha element, it wont register and adjust for the screen width. Even though this happens on all smaller screen-sizes, it seems to especially apply for screen widths of 414px.
Skjermbilde 2019-10-16 kl  16 42 21

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.