1.0.1 • Published 3 years ago
@cloudmpower/hcaptcha-cmp v1.0.1
hcaptcha-module
hCaptcha integration with Nuxt.js
Usage
- Install
npm i hcaptcha-cmpor using yarn
yarn add hcaptcha-cmp- Add
hcaptcha-cmpmodule innuxt.config.js
export default {
modules: ["hcaptcha-cmp"],
};- Specify your site key in
nuxt.config.js
export default {
hcaptcha: {
siteKey: process.env.HCAPTCHA_SITE_KEY || "",
},
};- Add
<hcaptcha>component inyour-component.vue
<template>
<div>
<hcaptcha />
</div>
</template>- You are ready to go. get the response and send it to the server then validate it
In your-component.vue
<script>
export default {
methods: {
onSubmit() {
const hcaptcha_response = this.$hcaptcha.getResponse();
},
},
};
</script>Local Development
For local development, as modern browsers have strict CORS CORB,
hCaptcha will not work on file://somewhere either localhost
add 127.0.0.1 your.domain.com to the hosts to prevent this.
/etc/hostson Linux,/private/hostson OSX,%SystemRoot%/System32/drivers/etc/hostson Windows.
License
MIT