Skip to content

Commit

Permalink
Merge pull request #23 from apriendeau/master
Browse files Browse the repository at this point in the history
Update proxy to support analytics 2.0
  • Loading branch information
pooyaj authored Mar 8, 2022
2 parents 9af6228 + b13b796 commit 87956b4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ func NewSegmentReverseProxy(cdn *url.URL, trackingAPI *url.URL) http.Handler {
director := func(req *http.Request) {
// Figure out which server to redirect to based on the incoming request.
var target *url.URL
if strings.HasPrefix(req.URL.String(), "/v1/projects") || strings.HasPrefix(req.URL.String(), "/analytics.js/v1") {
switch {
case strings.HasPrefix(req.URL.String(), "/v1/projects"):
fallthrough
case strings.HasPrefix(req.URL.String(), "/analytics.js/v1"):
fallthrough
case strings.HasPrefix(req.URL.String(), "/next-integrations"):
fallthrough
case strings.HasPrefix(req.URL.String(), "/analytics-next/bundles"):
target = cdn
} else {
default:
target = trackingAPI
}

Expand Down

0 comments on commit 87956b4

Please sign in to comment.