apm-agent-rum-js
apm-agent-rum-js copied to clipboard
Instrumenting with `fetch` enabled removes the `Origin` header, among others
Hi I'm currently exploring apm rum and how to set it up for our website, but are having some issues when the fetch
instrumentation is enabled, namely that all our own outgoing API calls fails with CORS error. This is not CORS to apm-server but CORS in our own API that is failing.
Said simply, if the fetch
instrumentation is enabled, our Origin
header, along with many others, is gone from all outgoing requests.
Here is an API request normally:
Here is the same API request with fetch instrumented/patched:
As you can see, I have a custom header that is being carried over when fetch is patched, but Origin
(and many others) is not, so our CORS fails. This is the preflight request that failed so it would be a bit different than a "normal" request, but still, we need that Origin header.
I've traced it down to this line and confirmed that Origin
is set in init
but I can't read it back out in request
after that line
Some context info:
- I'm running elastic, kibana and fleet locally using the docker-compose from https://github.com/elastic/apm-server and running apm-server by running runapm in the same repo, so this is all on my machine/localhost except the API I'm calling.
- Other instrumentations (
page-load
,history
,eventtarget
,error
) are collected correctly out of the box and showing up in my APM traces in Kibana on localhost.
Let me know if you need more info :)