Skip to content

Custom baseUrl does not work when using ConfigCat Proxy #29

Closed
@croemmich

Description

@croemmich

Describe the bug

We're running the ConfigCat Proxy (v0.4.2) and have set a custom baseUrl. The initial config fetch works however subsequent fetches do not.

The issue lies in how preferences from the response are being handled:

suspend fun fetch(eTag: String): FetchResponse {
val currentUrl = baseUrl.value
val response = fetchHTTPWithPreferenceHandling(currentUrl, eTag)
val newUrl = response.entry.config.preferences?.baseUrl ?: currentUrl
baseUrl.update { newUrl }
return response
}

response.entry.config.preferences?.baseUrl is https://cdn-global.configcat.com. As such, baseUrl.update { "https://cdn-global.configcat.com" } is being called, which breaks the client.

I'm not sure if this should be fixed in the client or if the proxy should be re-writing the baseUrl.

I also don't love that the redirect preference can force the baseUrl to update when using the proxy.

SDK version

com.configcat:configcat-kotlin-client-jvm:3.0.0

SDK configuration

ConfigCatClient("configcat-proxy/my-sdk") {
    baseUrl = "http://proxy-url"
}

Logs

2024-04-09 16:44:59 UTC [ERROR]: ConfigCat - [1100] Your SDK Key seems to be wrong. You can find the valid SDK Key at https://app.configcat.com/sdkkey. Received response: 403

Language/Framework version

Kotlin 1.9.23
Java 21

Platform

Mac/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions