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

fix: send json accept headers for POST requests #1139

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

BryanttV
Copy link
Contributor

Description

This PR solves a CORS error when calling the endpoints for Changing Site Language and Unlinking the SSO Account. To resolve this error we simply specify the Accept: 'application/json' header in the request.

These are the related issues:

Testing Instructions

The changes have been tested in a local environment with Tutor v18.1.3.

  1. In your Tutor environment clone the Account MFE with these changes.
  2. Create a mount with tutor mounts add frontend-app-account
  3. Run tutor dev start -d to recreate the containers.
  4. Inside the Account MFE folder run npm install
  5. Finally run tutor dev restart

Changing Site Language

  1. Go to the Account Settings > Site Preferences.
  2. Click Edit next to Site language.
  3. Pick a language.
  4. Click Save.
  5. CORS error does not appear.

Unlinking the SSO Account

  1. Configure TPA auth for Open edX.
  2. Login or Register via third-party authentication.
  3. Go to Account Settings > Linked Accounts
  4. Click Unlink {TPA_Name} account.
  5. CORS error does not appear.

Screenshots

Before After
image image
image image

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Sandbox, if applicable.
  • Is there adequate test coverage for your changes?

Post-merge Checklist

  • Deploy the changes to prod after verifying on stage or ask @openedx/edx-infinity to do it.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 16, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @BryanttV!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/edx-infinity. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@BryanttV
Copy link
Contributor Author

Hi! @mariajgrimaldi @arbrandes, here is the solution to correct the CORS error. I look forward to any questions or comments.

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 58.53%. Comparing base (434f114) to head (8a4eecf).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/account-settings/site-language/service.js 0.00% 2 Missing ⚠️
.../account-settings/third-party-auth/data/service.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1139      +/-   ##
==========================================
- Coverage   58.61%   58.53%   -0.08%     
==========================================
  Files         117      117              
  Lines        2317     2320       +3     
  Branches      644      641       -3     
==========================================
  Hits         1358     1358              
- Misses        898      901       +3     
  Partials       61       61              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BryanttV
Copy link
Contributor Author

Hi @mariajgrimaldi @arbrandes, Although this change fixes the CORS error, according to the tests I did locally the language is still not being changed until the page is reloaded.

@BryanttV
Copy link
Contributor Author

Hi, @mariajgrimaldi @arbrandes. I did another test using a tutor plugin instead of a mount. Now, it updates the language without reloading the page. I'm not sure why the mount doesn't work.

account-mfe-1139.mp4

I switched to each language and as reported in the issue, some don't work.

  • en ✅
  • ar ✅
  • ca ❌ (Switches to English automatically)
  • es-419 ✅
  • fa-ir ✅
  • fr ❌ (Switches to English automatically)
  • he ✅
  • id ✅ (But the translation file is not in Indonesian (?))
  • ko-kr ❌ (Switches to English automatically)
  • pl ❌ (Switches to English automatically)
  • pt-br ✅
  • ru ✅
  • th ✅
  • uk ✅
  • zh-cn ✅
  • pt-pt ✅
  • it-it ✅
  • de-de ✅
  • hi ✅
  • fr-ca ✅
  • te ✅
  • da ✅
  • el ✅
  • es-es ✅
  • sw ✅
  • tr-tr ✅

None of the 4 failing ones is here.

@mariajgrimaldi
Copy link
Member

mariajgrimaldi commented Oct 18, 2024

Great news, @BryanttV! Thank you so much for testing this out. I'll try to get someone to review this :)

@arbrandes arbrandes assigned arbrandes and unassigned arbrandes Oct 21, 2024
@arbrandes arbrandes self-requested a review October 21, 2024 14:56
@arbrandes
Copy link
Contributor

Starting to review now.

Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

I tested this, and it works! Thank you!

@arbrandes arbrandes merged commit 8ce7362 into openedx:master Oct 22, 2024
9 of 11 checks passed
mariajgrimaldi pushed a commit to eduNEXT/frontend-app-account that referenced this pull request Oct 23, 2024
…ccept

fix: send json accept headers for POST requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants