feat: Allow withCredentials
for XHR
#557
Merged
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.
What is it?
Description
Partytown currently doesn't allow the
withCredentials
option for XHR, which makes it impossible to set first party cookies from subdomains. This feature / fix would allow using Partytown with a Tagging Server.Since I don't know the initial motivation to disable the feature, I've added a configuration to opt into allowing
withCredentials
. I would add documentation in case this is the preferred solution. Otherwise we could also just not blockwithCredentials
in any case.Use cases and why
Checklist:
Test Comment:
I struggled to write a test for this use-case. I've tried extensively to set first-party cookies through a subdomain on localhost, but due to cookie and localhost restrictions, I'm not sure it's possible.
The added test checks for cookies set through XHR and fetch with the
Set-Cookie
header, but this easily gets passed because they are not cross-domain.In case anyone has an idea how to tackle this specific test case without leaving the scope of the repository, I'd be very happy to discuss details.