Support desktop API base URL override

This commit is contained in:
Amer Agovic
2026-05-10 17:56:11 -05:00
parent 08f277486a
commit 8960e40db4
2 changed files with 40 additions and 3 deletions
+18 -1
View File
@@ -52,6 +52,23 @@ class APIClient {
);
}
/**
* Resolve an endpoint against the configured API base URL
* @param {string} endpoint
* @returns {string}
*/
resolveURL(endpoint = '') {
return `${this.baseURL}${endpoint}`;
}
/**
* Replace the configured API base URL for future requests.
* @param {string} baseURL
*/
setBaseURL(baseURL = '/api') {
this.baseURL = baseURL || '/api';
}
/**
* Make API request
* @param {string} endpoint
@@ -59,7 +76,7 @@ class APIClient {
* @returns {Promise<Response>}
*/
async request(endpoint, options = {}) {
const url = `${this.baseURL}${endpoint}`;
const url = this.resolveURL(endpoint);
const config = this._applyRequestInterceptors({
...options,
headers: {