MFE failing login_refresh with 404 error

When trying to access a course page, the browser developer console is reporting a 404 error when trying to post to the login_refresh endpoint. When looking a little deeper, the interesting thing is that it is actually try to post to the wrong endpoint http://{MFE_LEARNING_HOST}/learning/course/course-v1:edX+DemoX+Demo_Course/'http://{LMS_HOST}/login_refresh' including the extra quotes.

I put a breakpoint to see the value in config.js REFRESH_ACCESS_TOKEN_ENDPOINT: process.env.REFRESH_ACCESS_TOKEN_ENDPOINT, which is showing to contain extra encapsulating single quotes "'http://{LMS_HOST}/login_refresh'" which is not getting interpreted as a url, and therefore getting appended as the path on the end of the current endpoint when executing the post request.

I was able to resolve the issue by modifying tutormfe/templates/mfe/build/mfe/env/development to remove the single quotes from each line. After running tutor config save and rebooting the learning image, the single quotes are gone and the post request is executing successfully.

Is this the right way to fix the issue? Is anyone else experiencing the same error? I’d be happy to open a pr if I’m on the right track, but wanted to check first.

Sorry if I am missing a more simple solution to this error.

Thanks in advance for your guidance.

note: MFE_LEARNING_HOST and LMS_HOST are used above to obfuscate my address, but the values are correct in my runtime environment

To add to this issue, my jwt token was still not getting recognized after the successful login_refresh api call. I have found that the cause was similar extra single quotes. This time the value of ACCESS_TOKEN_COOKIE_NAME was "'edx-jwt-cookie-header-payload'". So when the code looked for the cookie, it was not finding a cookie name that matched (including the extra quotes).

Since that setting is found in tutormfe/templates/mfe/build/mfe/env/production it would seem that the quotes need to be removed from there as well. However, I’m still not clear on the implications of removing these quotes and whether they will break any other flows. So I am extra hesitant to remove them from the production settings file.

I’m also unclear why this issue understanding the production settings only appears to happen when running tutor dev but not tutor local.

I have confirmed that when I revert my changes so that the production config file includes the single quotes and then run the platform with tutor local everything works as expected. With my breakpoints, I see that the values do not show extra single quotes. So I wonder if the difference between the two environments, has something to do with how the config files are loaded by the different processes.

If I am reading the files correctly, it appears the env config files are loaded for the dev process in the dev/docker-compose.yml. In contrast, the prod env is loaded as part of the build of the image in Dockerfile.

Jeff, i am not using tutor, i deployed the latest branch/master, i had the refresh_token problem too, my way is:
1: set lms/envs/ JWT_IN_COOKIE_EXPIRATION=606024
2: set frontend-app-learning .env.development `SESSION_COOKIE_DOMAIN=‘xxx’ //set your dormain
this works for me.

@regis I reverted all of my changes to run vanilla tutor dev as you recommended on my other post Using tutor dev on remote AWS instance - #8 by regis. However, I’m still encountering this issue with extra single-quotation-marks in the env config, though when the quotes are removed from the development template as I mentioned in my original post works as expected. Can you please advise if I’m missing an easy solution?

Thank you once again for your patience and guidance!

I found this docker issue report which explains the change in docker-compose env_file behavior in handling quotation marks. I have been using the latest docker-compose version in the apt repository which is only version 1.25.0. The fix for escaping quotations was introduced in 1.26.0. Upgrading to docker-compose version 1.29.2 has resolved the issue. Here are instructions to install using curl rather than apt to get the later version.

This is super interesting, I was not aware that older versions of docker-compose treated env files by including the quotes (both " and ') in their values.

It seems to me that we could attempt to be backward compatible by removing all single quotes from the tutor-mfe env files (production and development). @Jeff_Cohen would you like to open a pull request to address this issue?

@arbrandes did you see this? tl;dr: older versions of docker-compose include quotes in the values defined in environment files. Thus, to be backward compatible, we should not write:




in the following files:

Hi @regis. Thank you for the invitation to open a pr. I have created it here. Please let me know if there is a template or other details you prefer pr’s follow.

As this issue showed, my environment might be set up different than other developers. For extra diligence, could you please test that my branch works well in your workspace before merging into master?