feat(core): Add tunnel server helper #14137
Open
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.
Closes #13453 and gives a simpler path for #10309 and adding tunnel support to other frameworks.
The current tunnel troubleshooting docs suggest this code but it doesn't work with binary envelopes so breaks with compressed replay envelopes and attachments.
Rather than get users to parse their own envelopes for this info, this PR adds a
handleTunnelEnvelope
function to@sentry/core
which handles all the logic for forwarding envelopes.If your client DSN is the same as your server DSN, the above example code becomes:
If you want to forward envelopes for other DSNs, you can just pass an array as
dsnAllowList
in the options. Not sure about this naming. IsallowedDsns
better?We can further wrap the
handleTunnelEnvelope
function and expose more complete examples for each framework. For example we could expose a helper which takes aRequest
and returns aResponse
or export an API route ready to use.