feat(android): allow custom OkHttpClient via factory#1376
feat(android): allow custom OkHttpClient via factory#1376whydidoo wants to merge 2 commits intocallstack:mainfrom
Conversation
Replace direct OkHttpClient instantiation with a configurablefactory in companion object, enabling custom client configuration(SSL, interceptors, timeouts) from the host application.
|
@whydidoo is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 23fc64d The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the contribution! A couple of thoughts:
|
@bartekkrok Thanks for the replay. I will add documentation for this feature. As for iOS, can I do it in this PR? |
You can create separate for ios or separate including both platforms together. |
Replace direct OkHttpClient instantiation with a configurablefactory in companion object, enabling custom client configuration(SSL, interceptors, timeouts) from the host application.
Summary
Currently,
RemoteScriptLoadercreates a hardcodedOkHttpClient()instance with no way to customize it. This is a problem for apps that need custom HTTP configuration — for example, certificate pinning, custom SSL trust managers, logging interceptors, or proxy settings.This PR introduces a static
okHttpClientFactorylambda in acompanion object, allowing host applications to provide their ownOkHttpClientinstance before any network requests are made:The client is lazily initialized via by
lazy, so the factory is only called once on the first use.Test plan
okHttpClientFactory, a defaultOkHttpClient()is used (no regression).okHttpClientFactoryinApplication.onCreate()or a React Native module initializer with a custom interceptor, confirm the interceptor is invoked during remote script loading.