When attempting to enter a course's home on Learning MFE, Error: getLocale called before configuring i18n

Hello,

I have a Tutor local deployment installed. In the docker container for MFE, I have the learning MFE in the folder /openedx/dist/learning where the React production files are contained after the mfe build. However, when attempting to access a course from the “View Course” button I receive this error:

Error: getLocale called before configuring i18n. Call configure with messages first.
    at E (lib.js:151:11)
    at p (ErrorPage.jsx:26:40)
    at Va (react-dom.production.min.js:153:146)
    at bu (react-dom.production.min.js:261:496)
    at ds (react-dom.production.min.js:246:265)
    at As (react-dom.production.min.js:246:194)
    at ns (react-dom.production.min.js:239:172)
    at Ju (react-dom.production.min.js:230:137)
    at Ls (react-dom.production.min.js:281:43)
    at react-dom.production.min.js:284:301

For my Caddyfile, it looks like:

[LMS URL], [CMS URL] {
    tls [KEY FILES]
    reverse_proxy 127.0.0.1:8000
    reverse_proxy 127.0.0.1:8001
    reverse_proxy /mfe/* localhost:5000
    header Set-Cookie "django_language=en-us"
    log {
        output file /var/log/caddy/access.log
        format single_field common_log
    }
}

In docker-compose.prod.yml

 mfe:
      image: docker.io/overhangio/openedx-mfe:15.0.5
      restart: unless-stopped
      volumes:
          - ../plugins/mfe/apps/mfe/Caddyfile:/etc/caddy/Caddyfile:ro
      depends_on:
          - lms

Also, in config.yml, I have:

USE_I18N: true
USE_L10N: true
EDXAPP_FEATURES:
MFE_ENABLED: true
PLUGINS:

  • forum
  • mfe

In addition, the login_refresh API call is returning 200 when loading the page as well.

I’m unsure on what is causing this issue and any help would be greatly appreciated.

1 Like

Hello, i still have the same problem. Please help.

1 Like

I have the same problem too

I have the same problem too, @regis do you have any recommendation regarding this issue?

This is just an error message, right? Does it cause any issue down the road? If yes, which one(s)?

It seems to cause a blank page for all of the MFE applications as attached. I’m not able to say any further issues until we can resolve this blank page issue.

Getting the same result also with Tutor 15.3.4

Yes i am getting a blank page too. Could it be related to the domain names. Because i am not using the default domain names. Such as:
My lms domain: lms.mydomain.com
My mfe domain: lmsapps.mydomain.com

Because of ssl restrictions i cant use it like apps.lms.mydomain.com

Just guessing here:
I had a simlair error when the MFE configuration for LANGUAGE_PREFERENCE_COOKIE_NAME was not set. It’s usually set to openedx-language-preference. You can ensure this the case for when opening development tools and check request/response header which include that cookie or through Application =>Storage => cookies from development tools.

This setting can be set at build time or through Dynamic config api, you can debug that there is a success request to mfe_domain/api/mfe_config/v1?mfe={APP_NAME} that request shall return something like this

{
  "BASE_URL": "apps.lms.zaat.dev",
  "CSRF_TOKEN_API_PATH": "/csrf/api/v1/token",
  "ACCOUNT_PROFILE_URL": "https://apps.lms.zaat.dev/profile",
  "CREDENTIALS_BASE_URL": "",
  "DISCOVERY_API_BASE_URL": "",
  "FAVICON_URL": "https://lms.zaat.dev/favicon.ico",
  "LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference",
  "LMS_BASE_URL": "https://lms.zaat.dev",
  "LOGIN_URL": "https://lms.zaat.dev/login",
  "LOGO_URL": "https://lms.zaat.dev/theming/asset/images/logo.png",
  "LOGO_WHITE_URL": "https://lms.zaat.dev/theming/asset/images/logo.png",
  "LOGO_TRADEMARK_URL": "https://lms.zaat.dev/theming/asset/images/logo.png",
  "LOGOUT_URL": "https://lms.zaat.dev/logout",
  "MARKETING_SITE_BASE_URL": "https://lms.zaat.dev",
  "REFRESH_ACCESS_TOKEN_ENDPOINT": "https://lms.zaat.dev/login_refresh",
  "SITE_NAME": "My Open edX",
  "STUDIO_BASE_URL": "https://studio.lms.zaat.dev",
  "USER_INFO_COOKIE_NAME": "user-info",
  "ACCESS_TOKEN_COOKIE_NAME": "edx-jwt-cookie-header-payload",
  "ACCOUNT_SETTINGS_URL": "https://apps.lms.zaat.dev/account",
  "LEARNING_BASE_URL": "https://apps.lms.zaat.dev/learning",
  "ENABLE_NEW_EDITOR_PAGES": true,
  "ENABLE_PROGRESS_GRAPH_SETTINGS": true,
  "DISABLE_ENTERPRISE_LOGIN": true,
  "ENABLE_DYNAMIC_REGISTRATION_FIELDS": true
}```

Getting the same result from the MFE APIs and it looks like LANGUAGE_PREFERENCE_COOKIE_NAME was set correctly.

Interestingly this issue seems to occur only when we do not use the default proxy settings as Caddy is not listening to 443 and MFE domain is set to something like mfe-lms.xxx.com rather than apps.lms.xxx.com.

{
    "BASE_URL": "{MFE_HOST}",
    "CSRF_TOKEN_API_PATH": "/csrf/api/v1/token",
    "ACCOUNT_PROFILE_URL": "https://{MFE_HOST}/profile",
    "CREDENTIALS_BASE_URL": "",
    "DISCOVERY_API_BASE_URL": "",
    "FAVICON_URL": "https://{LMS_HOST}/favicon.ico",
    "LANGUAGE_PREFERENCE_COOKIE_NAME": "openedx-language-preference",
    "LMS_BASE_URL": "https://{LMS_HOST}",
    "LOGIN_URL": "https://{LMS_HOST}/login",
    "LOGO_URL": "https://{LMS_HOST}/theming/asset/images/logo.png",
    "LOGO_WHITE_URL": "https://{LMS_HOST}/theming/asset/images/logo.png",
    "LOGO_TRADEMARK_URL": "https://{LMS_HOST}/theming/asset/images/logo.png",
    "LOGOUT_URL": "https://{LMS_HOST}/logout",
    "MARKETING_SITE_BASE_URL": "https://{LMS_HOST}",
    "REFRESH_ACCESS_TOKEN_ENDPOINT": "https://{LMS_HOST}/login_refresh",
    "SITE_NAME": "Olive Test",
    "STUDIO_BASE_URL": "https://{CMS_HOST}",
    "USER_INFO_COOKIE_NAME": "user-info",
    "ACCESS_TOKEN_COOKIE_NAME": "edx-jwt-cookie-header-payload",
    "LEARNING_BASE_URL": "https://{MFE_HOST}/learning",
    "ENABLE_NEW_EDITOR_PAGES": true,
    "ENABLE_PROGRESS_GRAPH_SETTINGS": true
}

But can you see from development console that this request is done? Also did you check the cookies exists see screenshot below

I suspect you don’t have the correct proxy settings, and thus MFE when trying to fetch config is routed incorrectly

The situation is the same for me. openedx-language-preference is set on the lms dashboard as seen in the picture.
image

But on the mfe profile page there are no cookies set at all. Here is the Network console:

Hummm I suppose you probably need to change this config SESSION_COOKIE_DOMAIN this a common problem if your mfe domain is not a subdomain of the lms. So for example if you have lms.mydomain.com and mfe.mydomain.com then SESSION_COOKIE_DOMAIN would need to be set a .mydomain.com as opposite of the default lms.mydomain.com. This settings can be changed through tutor file plugin i.e

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "lms-env-features",
        """
"SESSION_COOKIE_DOMAIN": ".mydomain.com"
"""
    )
)

save the above as a fiile in tutor plugins printroot assume you call the file cookie.py then the last step to enable it tutor plugins enable cookie. And probably restart the platform would be needed

3 Likes

Yes, the problem solved thank you so much. I applied the patch, and can see the SESSION_COOKIE_DOMAIN setting in lms.env.yml file. But there was another row below with the same key but with the default domain value. So I edited it manually and the problem solved.
I don’t know why my patch didn’t override the setting but i think i can handle the rest.
Thanks for your help.

2 Likes

the patch should be applied for lms-env then it will work

from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "lms-env",
        'SESSION_COOKIE_DOMAIN: ".mydomain.com"'
    )
)