Skip to content

Incorrect resolution of backend_api_url in frontend #44

@fc7

Description

@fc7

I am using the image quay.io/rh-aiservices-bu/rh-kb-chat:3.0.0 and noticed the following.

The file app/frontend/src/app/config.tsx contains incorrect code for resolving the backend_api_url:

const config = {
    backend_api_url: process.env.BACKEND_API_URL || window.location.protocol + '//' + window.location.hostname + '/api',
};

because process.env is only defined in Node.js at build time. In the compiled js bundle the above (after deobfuscation) results in this code:

const cu = {
            backend_api_url: "MISSING_ENV_VAR".BACKEND_API_URL || window.location.protocol + "//" + window.location.hostname + "/api"
        }

but the fallback value after || is likewise incorrect, because the port (by default 5555) is missing.

In my local environment with podman I can indeed see that the requests from the browser to the backend go to http://localhost/api/llms and http://localhost/api/collections, respectively, which obviously lead to net::ERR_CONNECTION_REFUSED.

However I believe the following config.tsx should work:

const config = {
    backend_api_url: window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/api'
}

export default config;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions