How to Change Account MFE Base URL from /account to /account-settings?

Hello everyone,

I have installed Open edX Teak using Tutor v20.0.2.
Currently, the Account MFE is accessible at:

https://apps.mylms.com/account/

I would like to change this base path to something like:

https://apps.mylms.com/account-settings/

So that all Account MFE routes are served under /account-settings instead of /account.

I would like to understand:

  1. Is it possible to change the base URL of the Account MFE in Tutor?
  2. Do I need to make any changes in the frontend-app-account source code? What?
  3. Are any changes required in Tutor’s Caddy configuration to map the new path?
  4. Is there any existing plugin, patch, or recommended approach in Open edX to achieve this?

I am using the standard Tutor deployment (no custom MFE hosting yet), and I want to make this change in a way that is maintainable across upgrades.

Thanks in advance.

Hi @Mahendra ,

You can control the base URL of the Account MFE (and other MFEs) via the ACCOUNT_MICROFRONTEND_URL and other settings present in lms/envs/common.py. The setting is defined here:

:link: edx-platform – ACCOUNT_MICROFRONTEND_URL

In a Tutor deployment, the recommended approach is to use openedx-lms-common-settings via a Tutor plugin.

I would suggest to use a Tutor plugin to add a custom MFE in addition because as you say you need to change Caddy to route to the new path, and for the MFE you need to change the definition of the PUBLIC_PATH env variable (needed during the build time)

I think what you need is something like this:

from tutormfe.hooks import MFE_APPS
from tutor import hooks


@MFE_APPS.add()
def _remove_some_my_mfe(mfes):
    mfes.pop("account")
    return mfes

@MFE_APPS.add()
def _add_my_mfe(mfes):

    mfes["account-settings"] = {
        "repository": "https://github.com/openedx/frontend-app-account.git",
        "port": 1997,
    }
    
    return mfes

hooks.Filters.ENV_PATCHES.add_item(
        (
            "mfe-lms-common-settings",
            """
ACCOUNT_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/account-settings/"
MFE_CONFIG["ACCOUNT_SETTINGS_URL"] = ACCOUNT_MICROFRONTEND_URL
    """
)
)

The other think could be like:

from tutor import hooks


hooks.Filters.ENV_PATCHES.add_items(
        [(
            "mfe-caddyfile",
            """
@mfe_account-settings {
    path /account-settings /account-settings/*
}
handle @mfe_account-settings {
    uri strip_prefix /account-settings
    root * /openedx/dist/account-settings
    try_files /{path} /index.html
    file_server
}
    """
    ),
    (
            "mfe-dockerfile-pre-npm-build-account",
            """
ENV PUBLIC_PATH='/account-settings/'
    """
    ),
    ( "mfe-lms-common-settings",
        """
ACCOUNT_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https://{% else %}http://{% endif %}{{ MFE_HOST }}/account-settings/"
MFE_CONFIG["ACCOUNT_SETTINGS_URL"] = ACCOUNT_MICROFRONTEND_URL
"""
    )
        ]
)

but not sure if works. I think the first option is better.

1 Like