karliuka / m2.ReCaptcha

Magento2. Extension is integrate Google Recaptcha with your Magento2 store.
Open Software License 3.0
31 stars 13 forks source link

Recaptcha doens't show on production mode! #16

Open mariamghalleb opened 5 years ago

mariamghalleb commented 5 years ago

Hi, i'm on magento 2.2.4, php7

When I switched to production mode, Recaptcha started to not show up anymore, capture I found this exception in the system logs:

[2018-12-17 18:43:24] main.CRITICAL: Exception message: Sorry, but the administrator denied subscription for guests. Please <a href="https://www.website.ca/en-ca/customer/account/create/">register</a>.
Trace: #0 /home/website/public_html/vendor/magento/module-newsletter/Controller/Subscriber/NewAction.php(124): Magento\Newsletter\Controller\Subscriber\NewAction->validateGuestSubscription()
#1 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Newsletter\Controller\Subscriber\NewAction->execute()
#2 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->___callParent('execute', Array)
#3 /home/website/public_html/app/code/Mageplaza/BetterPopup/Plugin/Controller/Subscriber/NewAction.php(85): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->Magento\Framework\Interception\{closure}()
#4 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Mageplaza\BetterPopup\Plugin\Controller\Subscriber\NewAction->aroundExecute(Object(Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor), Object(Closure))
#5 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->Magento\Framework\Interception\{closure}()
#6 /home/website/public_html/generated/code/Magento/Newsletter/Controller/Subscriber/NewAction/Interceptor.php(26): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->___callPlugins('execute', Array, NULL)
#7 /home/website/public_html/vendor/magento/framework/App/Action/Action.php(107): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->execute()
#8 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#9 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->___callParent('dispatch', Array)
#10 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#11 /home/website/public_html/generated/code/Magento/Newsletter/Controller/Subscriber/NewAction/Interceptor.php(39): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->___callPlugins('dispatch', Array, Array)
#12 /home/website/public_html/vendor/magento/framework/App/FrontController.php(55): Magento\Newsletter\Controller\Subscriber\NewAction\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#13 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#14 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#15 /home/website/public_html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#16 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#17 /home/website/public_html/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#18 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#19 /home/website/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#20 /home/website/public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#21 /home/website/public_html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#22 /home/website/public_html/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
#23 /home/website/public_html/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()
#24 /home/website/public_html/en-ca/index.php(28): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#25 {main} [] []
jeremycurny commented 5 years ago

Hi, I just had this issue on my side, if you check your html source, you will see that your code is actually broken. This is a side effect of the html minify

Here is a patch that I had to apply, I hope this will help you:

--- a/view/frontend/templates/head.phtml
+++ b/view/frontend/templates/head.phtml
@@ -6,5 +6,5 @@
  */
 ?>
 <?php if ($block->isEnabled()) : ?>
-   <script type="text/javascript" src='//www.google.com/recaptcha/api.js?render=explicit&hl=<?php echo $block->getLocale() ?>' defer></script>
+   <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?render=explicit&hl=<?php echo $block->getLocale() ?>" defer></script>
 <?php endif ?>

Html minify seems to remove everything after the "//" thinking that it's a PHP comment. Prefixed with "https:" this doesn't happen.