Skip to content

Commit 41e0b5f

Browse files
authored
frontend.cpp: use relative paths in fetch() (#4)
With absolute paths, there's no way to change base url.
1 parent a4f22d0 commit 41e0b5f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

examples/server/frontend.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ R"xxx(
443443
}
444444
const modelIdElement = document.getElementById('model-id');
445445
async function fetchModelId() {
446-
const response = await fetch('/model');
446+
const response = await fetch('model');
447447
const data = await response.json();
448448
let modelIdText = '';
449449
if (data.model) {
@@ -477,7 +477,7 @@ R"xxx(
477477
modelIdElement.textContent = modelIdText;
478478
}
479479
async function fetchSampleMethods() {
480-
const response = await fetch('/sample_methods');
480+
const response = await fetch('sample_methods');
481481
const data = await response.json();
482482
const select = document.getElementById('sample_method');
483483
data.forEach(method => {
@@ -488,7 +488,7 @@ R"xxx(
488488
});
489489
}
490490
async function fetchSchedules() {
491-
const response = await fetch('/schedules');
491+
const response = await fetch('schedules');
492492
const data = await response.json();
493493
const select = document.getElementById('schedule_method');
494494
data.forEach(schedule => {
@@ -499,7 +499,7 @@ R"xxx(
499499
});
500500
}
501501
async function fetchPreviewMethods() {
502-
const response = await fetch('/previews');
502+
const response = await fetch('previews');
503503
const data = await response.json();
504504
const select = document.getElementById('preview_mode');
505505
if (data) {
@@ -513,7 +513,7 @@ R"xxx(
513513
}
514514
}
515515
async function fetchTypes() {
516-
const response = await fetch('/types');
516+
const response = await fetch('types');
517517
const data = await response.json();
518518
const select = document.getElementById('type');
519519
if (data) {
@@ -526,7 +526,7 @@ R"xxx(
526526
}
527527
}
528528
async function fetchModels() {
529-
const response = await fetch('/models');
529+
const response = await fetch('models');
530530
const data = await response.json();
531531
const modelsSelect = document.getElementById('model');
532532
if (data.models.length > 0) {
@@ -650,7 +650,7 @@ R"xxx(
650650
}
651651
}
652652
async function fetchParams() {
653-
const response = await fetch('/params');
653+
const response = await fetch('params');
654654
const data = await response.json();
655655
document.getElementById('prompt').value = data.generation_params.prompt;
656656
document.getElementById('neg_prompt').value = data.generation_params.negative_prompt;
@@ -742,7 +742,7 @@ R"xxx(
742742
...(preview_interval && { preview_interval: parseInt(preview_interval) }),
743743
... (type && { type: type }),
744744
};
745-
const response = await fetch('/txt2img', {
745+
const response = await fetch('txt2img', {
746746
method: 'POST',
747747
headers: {
748748
'Content-Type': 'application/json'
@@ -753,7 +753,7 @@ R"xxx(
753753
const taskId = data.task_id;
754754
let status = 'Pending';
755755
while (status !== 'Done' && status !== 'Failed') {
756-
const statusResponse = await fetch(`/result?task_id=${taskId}`);
756+
const statusResponse = await fetch(`result?task_id=${taskId}`);
757757
const statusData = await statusResponse.json();
758758
if (status == 'Pending' && statusData.status != status) {
759759
setTimeout(() => {
@@ -858,4 +858,4 @@ R"xxx(
858858
</body>
859859
860860
</html>
861-
)xxx";
861+
)xxx";

0 commit comments

Comments
 (0)