-
Notifications
You must be signed in to change notification settings - Fork 838
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
CORS requirements on web exporters with navigator.sendBeacon #3062
Comments
For the Zipkin compatible mode of the Jaeger server, I'm if it is behaving in an expected way. Maybe @yurishkuro can chime in here? |
Zipkin receiver in Jaeger has a config option for cors. |
In https://www.jaegertracing.io/docs/1.35/cli/ I see the allowed headers and allowed origins, but I don't see the allow credentials response header. Is there somewhere else I should look for cors configs? |
Yes, but as stated in the OP it is missing With MIME types like |
Seems like easily added if needed. The full Options struct has a lot more fields than what Jaeger CLI flags currently support - https://github.com/rs/cors/blob/da52b0701de54d82f71776d634d4183b69c3a915/cors.go#L32 |
Having said that, maybe it's better to implement this in OTLP receiver, then Jaeger could use that as well. I prefer to spend less effort on supporting legacy formats like Zipkin. |
This works fine for me for now ~
After digging into the source code with debugger i found this, with the so without
|
Maybe we should include a way to force xhr or sendbeacon by config |
Yeah, this is what I have in my mind too. I'm thinking about introducing a new @opentelemetry/core-web package for web utilities that need to be shared across various web packages. Currently, those utils are located in the @opentelemetry/sdk-trace-web (e.g. https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-sdk-trace-web/src/utils.ts#L201). |
Maybe consider having xhr (or fetch considering how it's available in node v18+, deno v1 and usually polyfilled in IE) as the default method in general and navigator.sendBeacon as backup when in browser document is being unloaded?
What this rule means is all sendBeacon calls to third-party domains should be blocked, meaning all data from users with this adblock list enabled would be missing
|
In my opinion, xhr or fetch is more predictable ~ |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stale for 14 days with no activity. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stale for 14 days with no activity. |
navigator.sendBeacon
with non-simplecontent-type
header like "application/json" requires CORS checks like Access-Control-Allow-Headers, Access-Control-Allow-Methods, Access-Control-Allow-Origin, and Access-Control-Allow-Credentials to be set with appropriate values on preflight requests.Notably,
sendBeacon
initialize the request withcredential mode
set totrue
with a non-simplecontent-type
, which means the server has to respond to preflight requests with Access-Control-Allow-Credentialstrue
too. This is not configurable nor an option exposed with thesendBeacon
API. That is to say, credentials like cookies, authorization headers or TLS client certificates are sent withsendBeacon
in this case. However, thecredential mode
is configurable withfetch
and XHR APIs.We have the following use cases on
sendBeacon
:application/json
content type, not tested if OTLP server responds with proper CORS headers.text/plain
, so the problem does not apply to Zipkin backends.text/plain
content-type, and doesn't respond withAccess-Control-Allow-Credentials
CORS header. (issue: exporter-zipkin does not send Content-Type in default config #1727)Currently, we don't provide options on how those data are sent, like sent with fetch (environments that don't support XHR or beacon), XHR or beacon, and the CORS credential modes like
omit
orinclude
. I think it may be worthwhile to add a package that shares all the necessary setups on the web platform.The text was updated successfully, but these errors were encountered: