fix(api): move origin outside try block in email subscription handlers#67624
Merged
majestic-owl448 merged 3 commits intoJun 18, 2026
Merged
Conversation
Contributor
|
Hi there, Thanks for opening this pull request. The automated checks found some issues: Checklist: The PR description is missing the required checklist or some of its items are not completed:
Please edit your PR description to include the following template with the checklist items completed. Checklist:
<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. -->
- [ ] I have read and followed the [contribution guidelines](https://contribute.freecodecamp.org).
- [ ] I have read and followed the [how to open a pull request guide](https://contribute.freecodecamp.org/how-to-open-a-pull-request/).
- [ ] My pull request targets the `main` branch of freeCodeCamp.
- [ ] I have tested these changes either locally on my machine, or GitHub Codespaces.
<!--If your pull request closes a GitHub issue, replace the XXXXX below with the issue number.-->
Closes #XXXXX
<!-- Feel free to add any additional description of changes below this line -->Linked Issue: The linked issue is not open for contribution. If you are looking for issues to contribute to, please check out issues labeled Join us in our chat room or our forum if you have any questions or need help with contributing. |
4 tasks
4 tasks
majestic-owl448
approved these changes
Jun 18, 2026
majestic-owl448
left a comment
Contributor
There was a problem hiding this comment.
Thank you for your contribution to the page! 👍
We are happy to accept these changes and look forward to future contributions. 🎉
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In both the
/ue/:unsubscribeIdand/resubscribe/:unsubscribeIdhandlers inemail-subscription.ts,originwas declared inside thetryblock. Sinceconstis block-scoped, thecatchblock could not access it.If an unexpected error occurred (for example, a Prisma connection failure), the
catchblock itself would throw:This caused the request to return a
500response instead of performing a graceful redirect with an error message.Before
After
Changes
getRedirectParams(req)outside thetryblock in the unsubscribe handlergetRedirectParams(req)outside thetryblock in the resubscribe handlerAffected File
api/src/routes/public/email-subscription.tsChecklist:
mainbranch of freeCodeCamp.Closes #67623