Skip to content

amp-recaptcha-input and SSR: ('TypeError: Cannot read property 'message' of null')? #22279

@dylanfpaul

Description

@dylanfpaul

What's the issue?

When clicking the submit button of a form that has an amp-recaptcha-input component, I get the error "TypeError: Cannot read property 'message' of null
at recaptcha.js:159".

Looking into the code of recaptcha.js where the error was being thrown, I noticed that the function it was inside of is taking the window object possibly as a parameter:

function actionTypeHandler(win, grecaptcha, data) {
  doesOriginDomainMatchIframeSrc(win, data).then(() => {
    const executePromise = grecaptcha.execute(sitekey, {
      action: data.action,
    });

    // .then() promise pollyfilled by recaptcha api script
    executePromise./*OK*/then(function(token) {
      iframeMessagingClient./*OK*/sendMessage('amp-recaptcha-token', dict({
        'id': data.id,
        'token': token,
      }));
    }, function(err) {
      user().error(TAG, '%s', err.message);
      iframeMessagingClient./*OK*/sendMessage('amp-recaptcha-error', dict({
        'id': data.id,
        'error': err.message,
      }));
    });
  }).catch(error => {
   // ERRORS OUT HERE ~~
    dev().error(TAG, '%s', error.message);
  });
}

Could this possibly because I am building and sending the AMP Documents via SSR? Everything seems to be configured according to documentation, however it does not append any recaptcha token to the POST request body hence the error.

Which AMP version is affected?

AMP Version 1904301721170

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions