Skip to content

Implement recaptcha in expo web #56

@Davete0302

Description

@Davete0302

I'm trying to implement recaptcha but keep getting errors cannot read properties of undefined (reading 'postMessage')

import WebView from 'react-native-webview';

 const getWebviewContent = () => {
        var originalForm = '<!DOCTYPE html><html><head><script src="https://www.google.com/recaptcha/api.js"></script></head><body><form action="[POST_URL]" method="post"><input type="hidden" value="[TITLE]"><input type="hidden" value="[DESCRIPTION]"><input type="hidden" value="[URL]"><div class="g-recaptcha" data-sitekey="<site-key>"></div><input type="submit" value="Send"/></form></body></html>'
        var tmp = originalForm
            .replace("[POST_URL]", "http://localhost:19006/Contact")
            .replace("[TITLE]", 'title')
            .replace("[DESCRIPTION]", 'description')
            .replace("[URL]", 'http://localhost:19006/Contact');

        return tmp;

    }

 <WebView
     javaScriptEnabled={true}
     mixedContentMode={'always'}
     style={{ height: 500, width: 500 }}
     source={{
     html: getWebviewContent(),
     baseUrl: '<domain>' // <-- SET YOUR DOMAIN HERE
   }} />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions