Proxy Sending
If your application needs to send requests through a proxy you can configure Raygun4JS to point at a different API endpoint. Requests made will then need to be forwarded to the Raygun API.
Configuring your API Endpoint
By default Raygun4JS sends requests to https://api.raygun.io
. To change this endpoint by using the apiEndpoint
option and setting it to a URI which points to your proxy. The URI needs to contain the protocol, domain and (optionally) a port. Payloads will then be sent to this address instead of https://api.raygun.io
.
rg4js('options', {
apiEndpoint: 'https://raygun.mydomain.com', // Change to your proxy's endpoint
});
Required API Endpoints
Raygun4JS sends Crash Reporting error payloads and Real User Monitoring session payloads to the following two endpoints. When configuring your proxy you need to make sure requests made to the following URIs and then forwarded to our API with their headers intact.
Crash Reporting
Sends error payloads via POST to https://api.raygun.io/entries
Real User Monitoring
Sends session payloads via POST to https://api.raygun.io/events
Sending the user's IP address
Real User Monitoring uses the IP address sent with requests to find the location of your users so you can understand the performance impact. When forwarding information through a proxy this functionality can break as the IP sent will be from your proxy's machine. To maintain this functionality you can either:
x-forwarded-for
Send the users IP with the proxy
Set the When forwarding requests via a proxy onto the Raygun API you can attach a x-forwarded-for
header to each payload. This value would be the user's IP address and the Raygun API will then associate these payloads with that IP provided.
clientIp
option
Use the If you can't configure the proxy to attach a new header you can use the clientIp
option in Raygun4JS to set your user's IP address. This will attach a x-remote-address
header to each request associating each payload to the IP provided. See the example below for an example of how this can work:
rg4js('clientIp', '192.168.0.2'); // Replace the IP with your user's IP address