DataDog/browser-sdk

Is it possible to change the proxy url after initialization?

Closed this issue · 1 comments

Hello there!

Is it possible to change proxy URL after RUM initialization?

Current setup:

init({
    ...,
    proxy: ({ parameters }) => 'https://proxy1.example.com'
});

Use case: Need to change proxy URL when users switch between instances during their session.

Is this currently possible? If not, what would be the recommended approach?

You can always return a different value from the proxy function:

init({

  proxy: ({ ... }) => {
    if (someCondition) {
      return 'https://a.com'
    }
    return 'https://b.com'
  }
})

Or:

let proxyUrl = 'https://a.com'

init({

  proxy: ({ ... }) => proxyUrl
})


// somewhere else:
proxyUrl = 'https://b.com'