Allow api_base override

Provide a means for local development to specify the api_base to override assumption that the api is where the client is based on browser 'location'
This commit is contained in:
Andre Molnar 2023-11-29 20:10:47 -05:00
parent d19de2753e
commit f73bf1cffd
3 changed files with 15 additions and 2 deletions

3
.gitignore vendored
View File

@ -14,4 +14,5 @@ venv/
/web/extensions/* /web/extensions/*
!/web/extensions/logging.js.example !/web/extensions/logging.js.example
!/web/extensions/core/ !/web/extensions/core/
/tests-ui/data/object_info.json /tests-ui/data/object_info.json
.vscode

View File

@ -7,6 +7,10 @@ class ComfyApi extends EventTarget {
this.api_base = location.pathname.split('/').slice(0, -1).join('/'); this.api_base = location.pathname.split('/').slice(0, -1).join('/');
} }
set apiBase(apiBase) {
this.api_base = apiBase;
}
apiURL(route) { apiURL(route) {
return this.api_base + route; return this.api_base + route;
} }
@ -314,7 +318,7 @@ class ComfyApi extends EventTarget {
*/ */
async interrupt() { async interrupt() {
await this.#postItem("interrupt", null); await this.#postItem("interrupt", null);
} }
} }
export const api = new ComfyApi(); export const api = new ComfyApi();

View File

@ -78,6 +78,14 @@ export class ComfyApp {
this.shiftDown = false; this.shiftDown = false;
} }
/**
* Provide a setter for the base url of the api
* @param {string} apiBase
*/
set apiBase(apiBase) {
api.apiBase = apiBase;
}
getPreviewFormatParam() { getPreviewFormatParam() {
let preview_format = this.ui.settings.getSettingValue("Comfy.PreviewFormat"); let preview_format = this.ui.settings.getSettingValue("Comfy.PreviewFormat");
if(preview_format) if(preview_format)