fix: client browser cookies being unnecessarily deleted#274
Open
josssch wants to merge 3 commits intohoppscotch:mainfrom
Open
fix: client browser cookies being unnecessarily deleted#274josssch wants to merge 3 commits intohoppscotch:mainfrom
josssch wants to merge 3 commits intohoppscotch:mainfrom
Conversation
added 3 commits
February 29, 2024 14:01
If a user is debugging with hoppscotch using a cookie for authorization, and they have one with the same name set it would just disappear. This commit fixes that bug by trying to return the cookie back to their original state. It also passes `credentials: "omit"` to the actual fetch to prevent it from doing any of the cookie handling as well.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Problem
This pull request aims to fix the issue that has been bugging me as a user of Hoppscotch for a while. The problem lied with how cookies were handled, where any cookie specified in the Hoppscotch request would be deleted from my browser after the request finished. I disagree with it working like that, as I believe the extension should leave my browser as untouched as possible.
This was especially a problem when developing and testing one of my backends before I knew this behavior existed, and has cost me more time than I'd like to admit trying to figure out why my session cookies were disappearing lol.
The Fix
This modifies the way cookies are handled by the
removeRequestCookies, by instead modifying it so pre-request we remember the state of the cookies before we change them. This lets theremoveRequestCookiesgo through all modified cookies and return them to their original state as best as it can.Other Things
formatscript to package.json to better make use of prettierNote: I have never touched the Chrome Extensions API before so apologies in advance for any oversights. I have not tested for Firefox.