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

feat: Allow withCredentials for XHR #557

Merged
merged 3 commits into from
Feb 24, 2024
Merged

feat: Allow withCredentials for XHR #557

merged 3 commits into from
Feb 24, 2024

Conversation

j0Shi82
Copy link
Contributor

@j0Shi82 j0Shi82 commented Feb 19, 2024

What is it?

  • Feature / enhancement
  • Bug?
  • Docs / tests

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 block withCredentials in any case.

Use cases and why

  • The ability to use a Tagging Server with Partytown

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

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.

Copy link

vercel bot commented Feb 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
partytown ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2024 4:39pm

@j0Shi82 j0Shi82 changed the title Allow withCredentials for XHR, closes #556 feat: Allow withCredentials for XHR, closes #556 Feb 19, 2024
Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

it looks great to me @j0Shi82
Having made it configurable is correct so everyone can decide what to do

@gioboa gioboa changed the title feat: Allow withCredentials for XHR, closes #556 feat: Allow withCredentials for XHR Feb 24, 2024
@gioboa gioboa linked an issue Feb 24, 2024 that may be closed by this pull request
@gioboa gioboa merged commit b2f9b0b into BuilderIO:main Feb 24, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐞] Web Worker Does Not Allow withCredentials for XHR Requests
2 participants