Skip to content

feat(nextjs): Add option for auto-generated random tunnel route #16626

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

Merged
merged 3 commits into from
Jun 18, 2025

Conversation

chargome
Copy link
Member

This PR adds support for auto-generated tunnel paths to avoid ad-blocker detection.

  • Random paths are less likely to be blocked than /monitoring
  • Users can just set tunnelRoute: true for an auto-generated route
  • Existing configs will still work

Note that every build will now create a different random path which should be quite unpredictable for ad-blockers

@chargome chargome self-assigned this Jun 17, 2025
@chargome chargome marked this pull request as draft June 17, 2025 22:38
Comment on lines +81 to +85
function generateRandomTunnelRoute(): string {
// Generate a random 8-character alphanumeric string
const randomString = Math.random().toString(36).substring(2, 10);
return `/${randomString}`;
}
Copy link
Member

Choose a reason for hiding this comment

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

Purely out of interestet, because I don't have context on how the SDK works in this case - how do we make sure these routes don't show up as endpoints in the data? Is this done by setUpTunnelRewriteRules?

Copy link
Member Author

Choose a reason for hiding this comment

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

We have an event processor in place that will filter these out. That being said I still need to figure out some details regarding value injection and test this manually

Comment on lines +110 to +111
// Update the global options object to use the resolved value everywhere
userSentryOptions.tunnelRoute = resolvedTunnelRoute;
Copy link
Member

Choose a reason for hiding this comment

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

Hm, is this the only way to pass the route around? Not a big fan of overwriting the passed in option but maybe this is bike-shedding.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seemed to be the most KISS variant I could think of here, because we can prevent the case that we have two different values floating around for the route

Copy link
Member

Choose a reason for hiding this comment

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

Yea, I guess fair enough.

@chargome chargome merged commit 57256ad into develop Jun 18, 2025
322 of 324 checks passed
@chargome chargome deleted the cg-next-randomize-tunnel branch June 18, 2025 14:36
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.

3 participants