Skip to content

Commit 226caf0

Browse files
mord0dstduhpf
authored andcommitted
frontend.cpp: use relative paths in fetch() (#4) (cherry-picked)
With absolute paths, there's no way to change base url.
1 parent 4a1fb94 commit 226caf0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

examples/server/frontend.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ R"xxx(
389389
}
390390
const modelIdElement = document.getElementById('model-id');
391391
async function fetchModelId() {
392-
const response = await fetch('/model');
392+
const response = await fetch('model');
393393
const data = await response.json();
394394
let modelIdText = '';
395395
if (data.model) {
@@ -423,7 +423,7 @@ R"xxx(
423423
modelIdElement.textContent = modelIdText;
424424
}
425425
async function fetchSampleMethods() {
426-
const response = await fetch('/sample_methods');
426+
const response = await fetch('sample_methods');
427427
const data = await response.json();
428428
const select = document.getElementById('sample_method');
429429
data.forEach(method => {
@@ -434,7 +434,7 @@ R"xxx(
434434
});
435435
}
436436
async function fetchSchedules() {
437-
const response = await fetch('/schedules');
437+
const response = await fetch('schedules');
438438
const data = await response.json();
439439
const select = document.getElementById('schedule_method');
440440
data.forEach(schedule => {
@@ -445,7 +445,7 @@ R"xxx(
445445
});
446446
}
447447
async function fetchPreviewMethods() {
448-
const response = await fetch('/previews');
448+
const response = await fetch('previews');
449449
const data = await response.json();
450450
const select = document.getElementById('preview_mode');
451451
if (data) {
@@ -459,7 +459,7 @@ R"xxx(
459459
}
460460
}
461461
async function fetchModelsEncodersAE() {
462-
const response = await fetch('/models');
462+
const response = await fetch('models');
463463
const data = await response.json();
464464
const modelsSelect = document.getElementById('model');
465465
if (data.models.length > 0) {
@@ -568,7 +568,7 @@ R"xxx(
568568
}
569569
}
570570
async function fetchParams() {
571-
const response = await fetch('/params');
571+
const response = await fetch('params');
572572
const data = await response.json();
573573
document.getElementById('prompt').value = data.generation_params.prompt;
574574
document.getElementById('neg_prompt').value = data.generation_params.negative_prompt;
@@ -655,7 +655,7 @@ R"xxx(
655655
...(preview_mode && { preview_mode: preview_mode }),
656656
...(preview_interval && { preview_interval: preview_interval }),
657657
};
658-
const response = await fetch('/txt2img', {
658+
const response = await fetch('txt2img', {
659659
method: 'POST',
660660
headers: {
661661
'Content-Type': 'application/json'
@@ -666,7 +666,7 @@ R"xxx(
666666
const taskId = data.task_id;
667667
let status = 'Pending';
668668
while (status !== 'Done' && status !== 'Failed') {
669-
const statusResponse = await fetch(`/result?task_id=${taskId}`);
669+
const statusResponse = await fetch(`result?task_id=${taskId}`);
670670
const statusData = await statusResponse.json();
671671
if (status == 'Pending' && statusData.status != status) {
672672
setTimeout(() => {
@@ -770,4 +770,4 @@ R"xxx(
770770
</script>
771771
</body>
772772
</html>
773-
)xxx";
773+
)xxx";

0 commit comments

Comments
 (0)