diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index cf1c45426..d29cbe222 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -424,7 +424,7 @@ async function loadWorldInfoData(name) { return worldInfoCache[name]; } - const response = await fetch('/getworldinfo', { + const response = await fetch('/api/worldinfo/get', { method: 'POST', headers: getRequestHeaders(), body: JSON.stringify({ name: name }), @@ -1402,7 +1402,7 @@ function createWorldInfoEntry(name, data, fromSlashCommand = false) { } async function _save(name, data) { - await fetch('/editworldinfo', { + await fetch('/api/worldinfo/edit', { method: 'POST', headers: getRequestHeaders(), body: JSON.stringify({ name: name, data: data }), @@ -1464,7 +1464,7 @@ async function deleteWorldInfo(worldInfoName) { return; } - const response = await fetch('/deleteworldinfo', { + const response = await fetch('/api/worldinfo/delete', { method: 'POST', headers: getRequestHeaders(), body: JSON.stringify({ name: worldInfoName }), @@ -2269,7 +2269,7 @@ export async function importWorldInfo(file) { jQuery.ajax({ type: 'POST', - url: '/importworldinfo', + url: '/api/worldinfo/import', data: formData, beforeSend: () => { }, cache: false, diff --git a/server.js b/server.js index 794f2db27..5c614e080 100644 --- a/server.js +++ b/server.js @@ -1060,7 +1060,7 @@ app.post('/getsettings', jsonParser, (request, response) => { }); }); -app.post('/getworldinfo', jsonParser, (request, response) => { +app.post('/api/worldinfo/get', jsonParser, (request, response) => { if (!request.body?.name) { return response.sendStatus(400); } @@ -1070,7 +1070,7 @@ app.post('/getworldinfo', jsonParser, (request, response) => { return response.send(file); }); -app.post('/deleteworldinfo', jsonParser, (request, response) => { +app.post('/api/worldinfo/delete', jsonParser, (request, response) => { if (!request.body?.name) { return response.sendStatus(400); } @@ -1132,7 +1132,7 @@ function getImages(path) { .sort(Intl.Collator().compare); } -app.post('/importworldinfo', urlencodedParser, (request, response) => { +app.post('/api/worldinfo/import', urlencodedParser, (request, response) => { if (!request.file) return response.sendStatus(400); const filename = `${path.parse(sanitize(request.file.originalname)).name}.json`; @@ -1167,7 +1167,7 @@ app.post('/importworldinfo', urlencodedParser, (request, response) => { return response.send({ name: worldName }); }); -app.post('/editworldinfo', jsonParser, (request, response) => { +app.post('/api/worldinfo/edit', jsonParser, (request, response) => { if (!request.body) { return response.sendStatus(400); } @@ -2134,6 +2134,12 @@ redirect('/creategroup', '/api/groups/create'); redirect('/editgroup', '/api/groups/edit'); redirect('/deletegroup', '/api/groups/delete'); +// Redirect deprecated worldinfo API endpoints +redirect('/getworldinfo', '/api/worldinfo/get'); +redirect('/deleteworldinfo', '/api/worldinfo/delete'); +redirect('/importworldinfo', '/api/worldinfo/import'); +redirect('/editworldinfo', '/api/worldinfo/edit'); + // ** REST CLIENT ASYNC WRAPPERS ** /**