Skip to content

Conversation

@Maddily
Copy link
Contributor

@Maddily Maddily commented Sep 2, 2024

Because

I wanted to mention the default behavior when sending cross-origin requests using fetch.

This PR

  • Mentions that, in case the request being sent is cross-origin, mode: 'cors'` is set by default.
  • Adds that explicitly specifying mode: 'cors' in the options is good for clarity.

Issue

Closes #XXXXX

Additional Information

N/A

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

@github-actions github-actions bot added the Content: JavaScript Involves the JavaScript course label Sep 2, 2024
@wise-king-sullyman wise-king-sullyman requested review from a team and thatblindgeye and removed request for a team September 3, 2024 14:11
@mao-sz
Copy link
Contributor

mao-sz commented Sep 4, 2024

We can actually probably just remove the { mode: 'cors' } bits entirely (from this lesson and a few other lessons in the curriculum) as that's the default mode for fetch. So the CORS section introducing that to "solve a problem" is redundant because there is no problem when omitted.

If you can put this on hold for a bit, I'm discussing with the team regarding some other CORS material because there might be an additional thing we need to do on top of removing the mode options references. I'll get back to you once we've discussed that through.

@Maddily
Copy link
Contributor Author

Maddily commented Sep 5, 2024

That makes sense. I'll put this on hold for now and wait for your update after the team discussion.

@Mclilzee
Copy link
Member

Mclilzee commented Sep 5, 2024

@MaoShizhong There was an Issue + PR I opened regarding this in the past. Maybe it is worth looking into why it was closed and not merged Check #23232

@Maddily Maddily closed this Sep 29, 2024
@Maddily Maddily deleted the patch-1 branch September 29, 2024 14:28
@Maddily Maddily restored the patch-1 branch September 29, 2024 14:29
@Maddily Maddily reopened this Sep 29, 2024
@mao-sz
Copy link
Contributor

mao-sz commented Nov 23, 2024

@wise-king-sullyman Did you ever get round to confirming this in Safari on MacOS? And discussing how CORS can be introduced in the Rails pathway?

@wise-king-sullyman
Copy link
Member

My apologies, this slipped through the cracks on me. I just tested in Safari and confirmed that fetch is defaulting to cors mode so I think we should be ok to remove it as @mao-sz suggested.

Would you still be interested in making this change @Maddily? I know it has been quite a while since you opened this PR.

@Maddily
Copy link
Contributor Author

Maddily commented Sep 1, 2025

@wise-king-sullyman Absolutely. I'm on it.

@Maddily
Copy link
Contributor Author

Maddily commented Sep 1, 2025

@mao-sz I've removed the cors references from this lesson as well as Fetching Data In React and Async and Await. Could you confirm if these were all the lessons that mentioned mode: 'cors', or if I missed any?

Copy link
Contributor

@mao-sz mao-sz left a comment

Choose a reason for hiding this comment

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

Many thanks! Sorry it took so long

@mao-sz mao-sz merged commit 4298f17 into TheOdinProject:main Sep 3, 2025
2 checks passed
@Maddily Maddily deleted the patch-1 branch September 4, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content: JavaScript Involves the JavaScript course

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants