Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add trailing slash to currentUserUrl #5

Merged
merged 2 commits into from
Feb 6, 2024
Merged

add trailing slash to currentUserUrl #5

merged 2 commits into from
Feb 6, 2024

Conversation

gumaerc
Copy link
Collaborator

@gumaerc gumaerc commented Feb 5, 2024

What are the relevant tickets?

Closes #4

Description (What does it do?)

This PR simply adds a trailing slash to the the API URL hitting /apiv/0/users/me to avoid a 301 redirection. 301 redirection breaks CORS requests, so this is necessary for the API request to not trigger a CORS error.

How can this be tested?

  • In order to test this, you will need a running instance of mit-open. Follow the instructions in the mit-open readme for initial setup. You will need an account in your local instance for this to work. Your instance of mit-open should be accessible at http://od.odl.local:8063. You will need to set the following environment variables:
CORS_ALLOWED_ORIGINS=["http://ocw.odl.local:3000"]
SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS=["ocw.odl.local:3000"]
  • You will also need ocw-hugo-themes (https://github.com/mitodl/ocw-hugo-themes) set up locally, running a course using yarn start course. Follow the readme there for basic setup instructions and make sure you can start up a course. After you have that working, check out the cg/add-mit-open-login-button branch. Assuming you have cloned this repo, run yarn add /path/to/mit-open-login-button to add your local copy of the code for this to your locally running ocw-hugo-themes. This is necessary because the package is not yet published to NPM. You will also need an entry in your hosts file that points the ocw.odl.local domain to 127.0.0.1.
  • Once you have all this running, make sure you are logged out of your local instance of mit-open
  • Back in your locally running OCW course site, you should see a Login button in the upper right. Click this button and log in to your locally running mit-open
  • After you have logged in, you will be sent to http://od.odl.local:8063
  • Go back to your locally running OCW site at http://ocw.odl.local:3000 and confirm that you see Logged in as: username with your username in place of username
  • In another tab, log out of your locally running mit-open
  • Verify that the login button reappears

@gumaerc gumaerc changed the title add trailing slash to apiUrl add trailing slash to currentUserUrl Feb 5, 2024
Copy link

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

👍 This worked for me. However, I just used

  • http://localhost:8063 for MIT Open
  • http://localhost:3000 for OCW

Which worked fine. I opened mitodl/ocw-hugo-themes#1310 to facilitate sharing this work within the team.

@ChristopherChudzicki ChristopherChudzicki added the Needs Review An open Pull Request that is ready for review label Feb 6, 2024
@gumaerc gumaerc merged commit 16077ff into main Feb 6, 2024
2 checks passed
@gumaerc gumaerc deleted the cg/fix-api-path branch February 6, 2024 19:30
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.

correct login status API URL
2 participants