Skip to content

Conversation

@harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Jan 15, 2026

πŸ”— Linked issue

Resolves #87

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Third-party scripts expose user data directly to external servers - every request shares the user's IP address, and scripts can set third-party cookies for cross-site tracking. Ad blockers rightfully block these for privacy reasons.

This PR adds a firstParty option that routes all script traffic through your own domain:

  • User IPs stay private - third parties see your server's IP, not your users'
  • No third-party cookies - requests are same-origin, eliminating cross-site tracking vectors
  • Reduced fingerprinting - fewer direct connections to tracking domains
  • Works with ad blockers - requests appear first-party

Scripts are downloaded at build time, collection URLs rewritten to local paths (/_scripts/c/ga), and Nitro route rules proxy requests to original endpoints.

// nuxt.config.ts
export default defineNuxtConfig({
  scripts: {
    firstParty: true,
    registry: {
      googleAnalytics: { id: 'G-XXXXXX' },
      metaPixel: { id: '123456' },
    }
  }
})

Supported: Google Analytics, GTM, Meta Pixel, TikTok, Segment, Clarity, Hotjar, X/Twitter, Snapchat, Reddit.

Includes new /docs/guides/first-party documentation and deprecation notice on bundling guide.

Combined commits:
- fix(plausible): use consistent window reference in clientInit stub
@vercel
Copy link

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
scripts-docs Error Error Jan 15, 2026 4:03pm
scripts-playground Ready Ready Preview, Comment Jan 15, 2026 4:03pm

- Add `scripts.firstParty` config option to route scripts through your domain
- Download scripts at build time and rewrite collection URLs to local paths
- Inject Nitro route rules to proxy requests to original endpoints
- Privacy benefits: hides user IPs, eliminates third-party cookies
- Add `proxy` field to RegistryScript type to mark supported scripts
- Deprecate `bundle` option in favor of unified `firstParty` config
- Add comprehensive unit tests and documentation

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@harlan-zw harlan-zw changed the title feat: add proxy mode for third-party script collection endpoints feat: add first-party mode for third-party script routing Jan 15, 2026
@harlan-zw harlan-zw changed the title feat: add first-party mode for third-party script routing feat: first-party mode Jan 15, 2026
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.

Investigate offloading entire scripts as a server proxy

2 participants