What kind of issue is this?
I am building a serverless app which does not know the base url until the users set it up. However, I am also using Dagger 2 to initialize the Retrofit RestAPI adapter when the application gets started before a user has an opportunity to configure the server base url. But Retrofit2 does not allow empty base url, which makes my app crash during the initialization of Dagger2. So far, I could resolve it by providing a dummy but valid http url and change it base url after the user configure the correct one. But this does not feel right. I am wondering whether there is a better solution or not?
Any suggestion will be appreciated.
You can either defer initialization of the Retrofit instance until the URL is known, or you can use a placeholder like http://localhost/ and use an OkHttp interceptor to rewrite all URLs with this host to whatever value is configured.
Thank you very much for the confirmation. I will try to use the delay initialization way.
Most helpful comment
You can either defer initialization of the Retrofit instance until the URL is known, or you can use a placeholder like
http://localhost/and use an OkHttp interceptor to rewrite all URLs with this host to whatever value is configured.