If your Magento 2 checkout stops working properly after an update, for example, inspect network requests in Chrome Developer Tools. If you see URLs containing undefinedrest , this article explains a possible fix.
Examples of undefinedrest URLs in Magento 2:
- https://domain.com/checkout/undefinedrest/en/V1/customers/isEmailAvailable
- https://domain.com/checkout/undefinedrest/en/V1/carts/mine/set-payment-information
- https://domain.com/checkout/undefinedrest/en/V1/carts/mine/estimate-shipping-methods
- https://domain.com/checkout/undefinedrest/en/V1/carts/mine/estimate-shipping-methods-by-address-id
The problem is very likely in your theme’s template templates/page/js/require_js.phtml . In most cases, the BASE_URL variable is missing. The correct template code is:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?> <script> var BASE_URL = '<?= $block->escapeUrl($block->getBaseUrl()) ?>'; var require = { "baseUrl": "<?= $block->escapeUrl($block->getViewFileUrl('/')) ?>" }; </script> |
Add this code to require_js.phtml (or remove your theme’s overridden require_js.phtml) and the undefinedrest issue in your Magento 2 checkout should be resolved.
Fixing checkout undefinedrest
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.