There is BASE_URL variable on the adminhtml pages (see ./vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml):

            var BASE_URL = 'http://.../admin/customer/';
            var FORM_KEY = '...';
            var require = {
                "baseUrl": "http://.../pub/static/version1540389051/adminhtml/Magento/backend/en_US"

/admin/ part of the BASE_URL is set in ./app/etc/env.php:

'backend' => [
    'frontName' => 'admin'

I need base url without the last part (/customer/) to compose links to any adminhtml route in my UI Component (not to only current route). Smth. like http://.../admin. Does Magento has a JS utility to extract adminhtml root URL or I should do it by myself?

], function (Column, utils) {
    "use strict";
    const length = BASE_URL.length;
    const lastCharOff = BASE_URL.substr(0, length - 1);
    const lastSlashPos = lastCharOff.lastIndexOf('/');
    const ROOT_URL = BASE_URL.substr(0, lastSlashPos);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.