Skip to content

Conversation

@ChristopherChudzicki
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki commented Oct 15, 2025

What are the relevant tickets?

All the PRs we make where we copy-and-paste the setup directions for mitxonline <> Learn.

Description (What does it do?)

This PR adds directions for running MITxOnline and MIT Learn locally in a way that they can communicate.

How can this be tested?

  1. Follow the directions in the README
  2. Sanity checks:
  3. Create a program with some required and elective courses. Useful things to know:
    • Create courses and programs with ./manage.py create_courseware, ./manage.py create_courseware_page; see --help for details. Note: program readable ids should start with program-v1:.
    • Add instructors/relevant data for your program in Wagtail at http://mitxonline.odl.local:8013/cms
  4. Run MITxOnline ETL against your local MITxOnline; ./manage.py backpopulate_mitxonline_data --delete, and ./manage.py backpopulate_mitxonline_data
  5. Ensure product-page-course feature flag is on in your personal posthog
  6. Try backpopulating mitxonline data against local, ./manage.py backpopulate_mitxonline_data
  7. Try Viewing a program page or course page, e.g., http://open.odl.local:8062/courses/COURSE_ID_HERE or http://open.odl.local:8062/programs/PROGRAM_ID_HERE

@ChristopherChudzicki ChristopherChudzicki added the Needs Review An open Pull Request that is ready for review label Oct 15, 2025
Copy link
Contributor

@dsubak dsubak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to hold off for another, more experienced review, but these instructions are pretty much bang on what I ended up figuring out when I set it up on my own. Thanks for the writeup!

@jkachel
Copy link
Contributor

jkachel commented Oct 16, 2025

The goal of this is to allow MITx Online and Learn to be set up so that MITx Online can have some data in it, and Learn can pull that data out for its needs, right? This seems OK for that purpose.

README.md Outdated

### Connecting with MITxOnline

Set up the [mitxonline](https://github.com/mitodl/mitxonline) as indicated there. _Note: A working OpenEdx installation is not necessary for integration with Learn._
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe place this sentence after setting the env variables below in MIT-Learn and MITx Online, and starting up both.

Also, OPENEDX_API_CLIENT_ID and OPENEDX_API_CLIENT_SECRET require values for the mitxonline app to start successfully, but they are not mentioned in that repo's README or included in the example .env file. They are mentioned in the "Using Tutor" instructions but I skipped that step.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this PR should also enable mitxonline users to log in via mit-learn's apisix/keycloak instance, but if so I could not validate that because something seems off with my local setup and I was unable to log in that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this PR should also enable mitxonline users to log in via mit-learn's apisix/keycloak instance, but if so I could not validate that because something seems off with my local setup and I was unable to log in that way.

Do you mean click login via MITxOnline login button? I had forgotten that does a surprising infinite loop. I'm not sure what causes that, but logging in via MIT Learn works.

@jkachel Do you have any idea? IMO not critical though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was getting that endless loop initially, then started adjusting other env values with best guesses and got apisix or keycloak errors instead.

KEYCLOAK_CLIENT_ID=apisix
KEYCLOAK_CLIENT_SECRET=HckCZXToXfaetbBx0Fo3xbjnC468oMi4 # pragma: allowlist-secret
KEYCLOAK_DISCOVERY_URL=http://kc.ol.local:8066/realms/ol-local/.well-known/openid-configuration
KEYCLOAK_REALM_NAME=ol-local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not log in with these settings. But the backpopulate command works regardless.

If the goal of this PR is just to backpopulate from a local mitxonline instance, then these keycloak settings can be omitted.

If the goal is also to allow login via MIT-Learn's apisix/keycloak instance, then something is off, maybe I have a bad or missing environment value somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbertrand If:

  • you could log into Learn via Learn frontend
  • but once logged into Learn, you weren't authenticated with MITxOnline

I believe the issue was an incorrect value of MITOL_API_DOMAIN. I missed it because I had been overwriting it locally so i could use learn.odl.local, but I've removed all those overrides and I'm now back to using open.odl.local

Copy link
Contributor

@gumaerc gumaerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been testing this on Ubuntu Linux 24.04. I was able to eventually get the dashboard connected and see my programs / enrollments on the frontend, after changing some of the settings I noted below. However, I was unable to get the program page in Learn working. When I try and load the page for my test program, I get "Error fetching course page metadata for programv1%3Aprogam-v1-test-program" (Yes, that is the readable ID of my test program). The message says "connect ECONNREFUSED 127.0.0.1:8065." This indicates that the API in the watch server (since the metadata seems to be queried by the server and not the client) has mitxonline.odl.local as the MITx Online base url, which is going to evaluate to 127.0.0.1. I think in the docker configuration, if we somehow get the watch container itself to use host.docker.internal:8013 for that, then it should work?

- MITX_ONLINE_UPSTREAM=${MITX_ONLINE_UPSTREAM:-mitxonline.odl.local:8013}
- MITX_ONLINE_DOMAIN=${MITX_ONLINE_DOMAIN:-mitxonline.odl.local}
- MITX_ONLINE_UPSTREAM=${MITX_ONLINE_UPSTREAM:-host.docker.internal:8013}
- MITX_ONLINE_DOMAIN=${MITX_ONLINE_DOMAIN:-host.docker.internal}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to set MITX_ONLINE_DOMAIN to mitxonline.odl.local. This allows you to access http://mitxonline.odl.local:8065/ in a browser and then, using your already logged in session in APISIX, you are automatically authenticated to use Django admin in MITx Online.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure what the issue was here, but I've changed so that docker.host.internal is not longer used and we just use mitxonline.odl.local everywhere.

Comment on lines +17 to +18
MAILGUN_KEY=fake
MAILGUN_SENDER_DOMAIN=open.odl.local
Copy link
Contributor Author

@ChristopherChudzicki ChristopherChudzicki Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These settings are new. They were in backend.env.example, are not secret, and some value is required for the app to work, so I think they should be in the defaults.

(I removed most of my local env vars to isolate what was actually necessary for mitxonline connection)

env/backend.env Outdated
CORS_ALLOWED_ORIGINS='["http://open.odl.local:8062"]'
CSRF_TRUSTED_ORIGINS='["http://open.odl.local:8062", "http://api.open.odl.local:8063"]'
CSRF_COOKIE_DOMAIN=open.odl.local
CSRF_COOKIE_DOMAIN=.odl.local
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the default value of this env var.

@ChristopherChudzicki ChristopherChudzicki force-pushed the cc/mitxonline-networking branch 2 times, most recently from c4ff3c8 to 81b26ec Compare October 22, 2025 23:05
@ChristopherChudzicki
Copy link
Contributor Author

@mbertrand @gumaerc This is ready for another look.

@mbertrand I tried to clarify the readme a bit, both in order and expected behavior of mitxonline.

I also dropped host.docker.internal for a scheme more similar https://github.com/mitodl/mitxonline/blob/29e6356817c1b88d34a08b442df293787873712b/docker-compose.yml#L21

extra_hosts:
# Both the browser and NextJS server (containerized) make requests to
# api.open.odl.local, forward those to host
- "api.open.odl.local:host-gateway"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gumaerc re

When I try and load the page for my test program, I get "Error fetching course page metadata for programv1%3Aprogam-v1-test-program" (Yes, that is the readable ID of my test program).

I suspect that was happening for all api-dependent metadata generation (though some of them may have fallbacks to static metadata w/o an api call), not just the mitxonline-specific ones.

This should fix it.

@dsubak
Copy link
Contributor

dsubak commented Oct 23, 2025

FWIW, I took another look at this and ran through the tests. Still looks good (I like the new extra_hosts approach)!

I'll note that I did hit 404s when attempting to hit http://learn.odl.local:8062/courses/COURSE_ID_HERE in step 10, but everything got populated at the database level afaict. Given my lack of familiarity, I wanted to note it, but unless anyone else hits the same, I'm operating on the assumption that I've messed something up and it's not an issue w/ these changes.

Copy link
Member

@mbertrand mbertrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can log in to mit-learn, then when I click the link to the mitxonline course, I am logged in to my local mitxonline as well - 👍

Login still doesn't work in the opposite direction - endless redirects when trying to log in to mitxonline first.

http://mitxonline.odl.local:8013/courses/course-v1:mycourse : works fine

http://open.odl.local:8062/courses/course-v1:mycourse : 404

@ChristopherChudzicki ChristopherChudzicki force-pushed the cc/mitxonline-networking branch 2 times, most recently from 327c70f to 6788e23 Compare October 23, 2025 19:14

```env
# MIT Learn, shared.local.env (ensure not overwritten in backend/frontend env)
MITX_ONLINE_BASE_URL=http://api.open.odl.local:8065/mitxonline
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbertrand I had this wrong previously, MITX_ONLINE_BASE_URL should be in shared (not backend) since it's used by the frontend, too.

Copy link
Member

@mbertrand mbertrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works with the latest changes (and turning off the browser's adblocker to let posthog through).

@ChristopherChudzicki ChristopherChudzicki merged commit 4788af3 into main Oct 24, 2025
18 of 19 checks passed
@ChristopherChudzicki ChristopherChudzicki deleted the cc/mitxonline-networking branch October 24, 2025 00:12
This was referenced Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants