Skip to content

Commit 5e9f8fc

Browse files
authored
add custom proxy section to README (#793)
1 parent 60fc8d9 commit 5e9f8fc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

packages/browser/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,40 @@ analytics
8484
.catch((err) => ...);
8585
```
8686

87+
## Custom CDN / API Proxy
88+
89+
You can proxy settings and destination requests that typically go to `http://cdn.segment.com` through a custom proxy.
90+
```ts
91+
const analytics = AnalyticsBrowser.load({
92+
writeKey,
93+
// GET http://cdn.segment.com/v1/projects/<writekey>/settings ->
94+
// https://MY-CUSTOM-CDN-PROXY.com/v1/project/<writekey>/settings
95+
96+
// GET https://cdn.segment.com/next-integrations/actions/...js ->
97+
// https://MY-CUSTOM-CDN-PROXY.com/next-integrations/actions/...js
98+
cdnURL: 'https://MY-CUSTOM-CDN-PROXY.com' // 🔥
99+
})
100+
```
101+
102+
You can proxy event calls that typically go to `https://api.segment.io` by configuring `integrations['Segment.io'].apiHost`.
103+
```ts
104+
const analytics = AnalyticsBrowser.load(
105+
{
106+
writeKey,
107+
cdnURL: 'https://MY-CUSTOM-CDN-PROXY.com'
108+
},
109+
{
110+
integrations: {
111+
'Segment.io': {
112+
// POST https://api.segment.io/v1/t ->
113+
// https://MY-CUSTOM-API-PROXY.com/v1/t
114+
apiHost: 'MY-CUSTOM-API-PROXY.com' // 🔥
115+
}
116+
}
117+
}
118+
)
119+
```
120+
87121
## Usage in Common Frameworks
88122
### React
89123
```tsx

0 commit comments

Comments
 (0)