Add content-type to sent requests

This commit is contained in:
Yukino Song
2025-05-28 14:09:12 +08:00
parent b2ec048333
commit f3d2078b11
7 changed files with 53 additions and 20 deletions

View File

@@ -599,7 +599,10 @@
fetch("./api/apps/reorder", { fetch("./api/apps/reorder", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify({order: reorderedUUIDs}) body: JSON.stringify({order: reorderedUUIDs})
}) })
.then(r => r.json()) .then(r => r.json())
@@ -636,7 +639,7 @@
this.actionDisabled = true; this.actionDisabled = true;
fetch("./api/apps/launch?uuid=" + app.uuid, { fetch("./api/apps/launch?uuid=" + app.uuid, {
credentials: 'include', credentials: 'include',
method: "POST", method: 'POST',
}) })
.then(r => r.json()) .then(r => r.json())
.then(r => { .then(r => {
@@ -655,7 +658,7 @@
this.actionDisabled = true; this.actionDisabled = true;
fetch("./api/apps/close", { fetch("./api/apps/close", {
credentials: 'include', credentials: 'include',
method: "POST" method: 'POST',
}) })
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {
@@ -681,7 +684,7 @@
this.actionDisabled = true; this.actionDisabled = true;
fetch("./api/apps/delete?uuid=" + app.uuid, { fetch("./api/apps/delete?uuid=" + app.uuid, {
credentials: 'include', credentials: 'include',
method: "POST" method: 'POST'
}).then((r) => r.json()) }).then((r) => r.json())
.then((r) => { .then((r) => {
if (!r.status) { if (!r.status) {
@@ -789,7 +792,10 @@
this.coverFinderBusy = true; this.coverFinderBusy = true;
fetch("./api/covers/upload", { fetch("./api/covers/upload", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
key: cover.key, key: cover.key,
url: cover.saveUrl, url: cover.saveUrl,
@@ -814,7 +820,10 @@
delete this.editForm.dragover; delete this.editForm.dragover;
fetch("./api/apps", { fetch("./api/apps", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(this.editForm), body: JSON.stringify(this.editForm),
}).then((r) => r.json()) }).then((r) => r.json())
.then((r) => { .then((r) => {

View File

@@ -437,7 +437,10 @@
return fetch("./api/config", { return fetch("./api/config", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(config), body: JSON.stringify(config),
}).then((r) => { }).then((r) => {
if (r.status === 200) { if (r.status === 200) {
@@ -460,7 +463,7 @@
this.saved = this.restarted = false; this.saved = this.restarted = false;
}, 5000); }, 5000);
fetch("./api/restart", { fetch("./api/restart", {
method: "POST" method: 'POST'
}) })
.then((resp) => { .then((resp) => {
if (resp.status !== 200) { if (resp.status !== 200) {

View File

@@ -89,7 +89,10 @@
localStorage.removeItem('login') localStorage.removeItem('login')
} }
fetch("./api/login", { fetch("./api/login", {
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(this.passwordData), body: JSON.stringify(this.passwordData),
}).then((res) => { }).then((res) => {
this.loading = false; this.loading = false;

View File

@@ -96,7 +96,10 @@
this.error = null; this.error = null;
fetch("./api/password", { fetch("./api/password", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(this.passwordData), body: JSON.stringify(this.passwordData),
}).then((r) => { }).then((r) => {
if (r.status === 200) { if (r.status === 200) {

View File

@@ -393,7 +393,10 @@
let b = JSON.stringify({pin: pin, name: name}); let b = JSON.stringify({pin: pin, name: name});
fetch("./api/pin", { fetch("./api/pin", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: b body: b
}) })
.then((response) => response.json()) .then((response) => response.json())
@@ -537,7 +540,10 @@
} }
fetch("./api/clients/update", { fetch("./api/clients/update", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(editedClient) body: JSON.stringify(editedClient)
}) })
.catch(err => { .catch(err => {
@@ -583,7 +589,10 @@
disconnectClient(uuid) { disconnectClient(uuid) {
fetch("./api/clients/disconnect", { fetch("./api/clients/disconnect", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify({ uuid }) body: JSON.stringify({ uuid })
}).finally(() => { }).finally(() => {
setTimeout(() => { setTimeout(() => {
@@ -595,7 +604,7 @@
this.unpairAllPressed = true; this.unpairAllPressed = true;
fetch("./api/clients/unpair-all", { fetch("./api/clients/unpair-all", {
credentials: 'include', credentials: 'include',
method: "POST" method: 'POST'
}) })
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {
@@ -610,7 +619,10 @@
unpairSingle(uuid) { unpairSingle(uuid) {
fetch("./api/clients/unpair", { fetch("./api/clients/unpair", {
credentials: 'include', credentials: 'include',
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify({ uuid }) body: JSON.stringify({ uuid })
}).then(() => { }).then(() => {
this.showApplyMessage = true; this.showApplyMessage = true;

View File

@@ -205,7 +205,7 @@
this.closeAppPressed = true; this.closeAppPressed = true;
fetch("./api/apps/close", { fetch("./api/apps/close", {
credentials: 'include', credentials: 'include',
method: "POST" method: 'POST'
}) })
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {
@@ -226,7 +226,7 @@
}, 5000); }, 5000);
fetch("./api/restart", { fetch("./api/restart", {
credentials: 'include', credentials: 'include',
method: "POST", method: 'POST',
}) })
.then((resp) => { .then((resp) => {
if (resp.status !== 200) { if (resp.status !== 200) {
@@ -250,7 +250,7 @@
this.serverQuitting = true; this.serverQuitting = true;
fetch("./api/quit", { fetch("./api/quit", {
credentials: 'include', credentials: 'include',
method: "POST", method: 'POST',
}) })
.then(() => { .then(() => {
this.serverQuitting = false; this.serverQuitting = false;
@@ -267,7 +267,7 @@
this.ddResetPressed = true; this.ddResetPressed = true;
fetch("/api/reset-display-device-persistence", { fetch("/api/reset-display-device-persistence", {
credentials: 'include', credentials: 'include',
method: "POST" method: 'POST'
}) })
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {

View File

@@ -81,7 +81,10 @@
this.error = null; this.error = null;
this.loading = true; this.loading = true;
fetch("./api/password", { fetch("./api/password", {
method: "POST", headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(this.passwordData), body: JSON.stringify(this.passwordData),
}).then((r) => { }).then((r) => {
this.loading = false; this.loading = false;