Skip to content

Commit a317414

Browse files
authored
Merge pull request #4414 from segmentio/update-proxy-js-docs
Clarify Proxy Docs
2 parents 8c7d865 + 59edf8a commit a317414

File tree

1 file changed

+13
-9
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+13
-9
lines changed

src/connections/sources/catalog/libraries/website/javascript/custom-proxy.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ A Segment Customer Success team member will respond that they have enabled this
6060
6161

6262
## Custom CDN / API Proxy
63+
Follow these instructions after setting up a proxy such as [CloudFront](#cloudfront). Choose between the [snippet instructions](#snippet-instructions) or the [npm instructions](#npm-instructions).
6364

6465
### Snippet instructions
6566
If you're a snippet user, you need to modify the [analytics snippet](/docs/getting-started/02-simple-install/#step-1-copy-the-snippet) that's inside your `<head>`.
6667

67-
To proxy settings and destination requests that typically go to `http://cdn.segment.com`, replace:
68+
To proxy settings and destination requests that typically go to `https://cdn.segment.com`, replace:
6869
```diff
6970
- t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"
7071
+ t.src="https://MY-CUSTOM-CDN-PROXY.com" + key + "/analytics.min.js"
@@ -73,21 +74,22 @@ To proxy settings and destination requests that typically go to `http://cdn.segm
7374
To proxy tracking calls that typically go to `api.segment.io/v1`, replace:
7475
```diff
7576
- analytics.load("<MY_WRITE_KEY>")
76-
+ analytics.load("<MY_WRITE_KEY>", { integrations: { "Segment.io": { apiHost: "MY-CUSTOM-API-PROXY.com" }}})
77+
+ analytics.load("<MY_WRITE_KEY>", { integrations: { "Segment.io": { apiHost: "MY-CUSTOM-API-PROXY.com/v1" }}})
7778
```
7879

7980
### npm instructions
8081
See the [`npm` library-users instructions](https://www.npmjs.com/package/@segment/analytics-next){:target="_blank"} for more information.
8182

82-
Proxy settings and destination requests that typically go to `http://cdn.segment.com` through a custom proxy.
83+
Proxy settings and destination requests that typically go to `https://cdn.segment.com` through a custom proxy.
8384

8485
```ts
8586
const analytics = AnalyticsBrowser.load({
8687
writeKey,
87-
// GET http://cdn.segment.com/v1/projects/<writekey>/settings ->
88-
// https://MY-CUSTOM-CDN-PROXY.com/v1/project/<writekey>/settings
89-
// GET https://cdn.segment.com/next-integrations/actions/...js ->
90-
// https://MY-CUSTOM-CDN-PROXY.com/next-integrations/actions/...js
88+
// GET https://MY-CUSTOM-CDN-PROXY.com/v1/project/<writekey>/settings --> proxies to
89+
// https://cdn.segment.com/v1/projects/<writekey>/settings
90+
91+
// GET https://MY-CUSTOM-CDN-PROXY.com/next-integrations/actions/...js --> proxies to
92+
// https://cdn.segment.com/next-integrations/actions/...js
9193
cdnURL: 'https://MY-CUSTOM-CDN-PROXY.com'
9294
})
9395
```
@@ -102,8 +104,10 @@ const analytics = AnalyticsBrowser.load(
102104
{
103105
integrations: {
104106
'Segment.io': {
105-
// POST https://api.segment.io/v1/t -> https://MY-CUSTOM-API-PROXY.com/t
106-
apiHost: 'MY-CUSTOM-API-PROXY.com' // omit the protocol (http/https) e.g. "api.segment.io/v1" rather than "https://api.segment.io/v1"
107+
// POST https://MY-CUSTOM-API-PROXY.com/v1/t --> proxies to
108+
// https://api.segment.io/v1/t
109+
apiHost: 'MY-CUSTOM-API-PROXY.com/v1',
110+
protocol: 'https' // optional
107111
}
108112
}
109113
}

0 commit comments

Comments
 (0)