diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 5460635e1d40..43f9db2aa8b0 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -11,6 +11,8 @@ export const meta = { tags: ['meta'], requireCredential: false, + allowGet: true, + cacheSec: 60, res: { type: 'object', diff --git a/packages/backend/src/server/api/endpoints/stats.ts b/packages/backend/src/server/api/endpoints/stats.ts index 1e6983177f64..286a82cc524d 100644 --- a/packages/backend/src/server/api/endpoints/stats.ts +++ b/packages/backend/src/server/api/endpoints/stats.ts @@ -12,6 +12,8 @@ import UsersChart from '@/core/chart/charts/users.js'; export const meta = { requireCredential: false, + allowGet: true, + cacheSec: 60, tags: ['meta'], diff --git a/packages/backend/src/server/web/boot.js b/packages/backend/src/server/web/boot.js index 6994feea3a57..c70e96edd6f7 100644 --- a/packages/backend/src/server/web/boot.js +++ b/packages/backend/src/server/web/boot.js @@ -32,6 +32,11 @@ renderError('FORCED_ERROR', 'This error is forced by having forceError in local storage.') } + if (localStorage.getItem('id') === null) { + localStorage.setItem('id', crypto.randomUUID().replaceAll('-', '')); + } + let id = localStorage.getItem('id'); + //#region Detect language & fetch translations if (!Object.hasOwn(localStorage, 'locale')) { let lang = localStorage.getItem('lang'); @@ -40,12 +45,11 @@ } const metaRes = await window.fetch('/api/meta', { - method: 'POST', - body: JSON.stringify({}), + method: 'GET', credentials: 'omit', - cache: 'no-cache', headers: { 'Content-Type': 'application/json', + 'X-Client-Transaction-Id': `${id}-misskey-${crypto.randomUUID().replaceAll('-', '')}` }, }); if (metaRes.status !== 200) { diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index 79ef7b3f2d67..48a8e1679e95 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -62,10 +62,6 @@ export async function common(createVue: () => App) { }); } - if (miLocalStorage.getItem('id') === null) { - miLocalStorage.setItem('id', crypto.randomUUID()); - } - let isClientUpdated = false; //#region クライアントが更新されたかチェック diff --git a/packages/frontend/src/components/MkVisitorDashboard.ActiveUsersChart.vue b/packages/frontend/src/components/MkVisitorDashboard.ActiveUsersChart.vue index b2cbf0b75e41..8fbbe31a6aae 100644 --- a/packages/frontend/src/components/MkVisitorDashboard.ActiveUsersChart.vue +++ b/packages/frontend/src/components/MkVisitorDashboard.ActiveUsersChart.vue @@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { onMounted, shallowRef, ref, nextTick } from 'vue'; import { Chart } from 'chart.js'; import tinycolor from 'tinycolor2'; -import { misskeyApi } from '@/scripts/misskey-api.js'; +import { misskeyApiGet } from '@/scripts/misskey-api.js'; import { defaultStore } from '@/store.js'; import { useChartTooltip } from '@/scripts/use-chart-tooltip.js'; import { chartVLine } from '@/scripts/chart-vline.js'; @@ -52,7 +52,7 @@ async function renderChart() { })); }; - const raw = await misskeyApi('charts/active-users', { limit: chartLimit, span: 'day' }); + const raw = await misskeyApiGet('charts/active-users', { limit: chartLimit, span: 'day' }); fetching.value = false; diff --git a/packages/frontend/src/components/MkVisitorDashboard.vue b/packages/frontend/src/components/MkVisitorDashboard.vue index 6e653ea4cce1..6a19f8abc487 100644 --- a/packages/frontend/src/components/MkVisitorDashboard.vue +++ b/packages/frontend/src/components/MkVisitorDashboard.vue @@ -79,7 +79,7 @@ import MkTimeline from '@/components/MkTimeline.vue'; import MkInfo from '@/components/MkInfo.vue'; import { instanceName } from '@/config.js'; import * as os from '@/os.js'; -import { misskeyApi } from '@/scripts/misskey-api.js'; +import { misskeyApiGet } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; import { instance } from '@/instance.js'; import { miLocalStorage } from '@/local-storage.js'; @@ -89,7 +89,7 @@ import { openInstanceMenu } from '@/ui/_common_/common'; const stats = ref(null); -misskeyApi('stats', {}).then((res) => { +misskeyApiGet('stats').then((res) => { stats.value = res; }); diff --git a/packages/frontend/src/instance.ts b/packages/frontend/src/instance.ts index 281affc3c00a..51b1a89338d4 100644 --- a/packages/frontend/src/instance.ts +++ b/packages/frontend/src/instance.ts @@ -5,7 +5,7 @@ import { computed, reactive } from 'vue'; import * as Misskey from 'misskey-js'; -import { misskeyApi } from '@/scripts/misskey-api.js'; +import { misskeyApiGet } from '@/scripts/misskey-api.js'; import { miLocalStorage } from '@/local-storage.js'; import { DEFAULT_INFO_IMAGE_URL, DEFAULT_NOT_FOUND_IMAGE_URL, DEFAULT_SERVER_ERROR_IMAGE_URL } from '@/const.js'; @@ -47,7 +47,7 @@ export async function fetchInstance(force = false): Promise { } }); -const initStats = () => misskeyApi('stats', { -}).then((res) => { +const initStats = () => misskeyApiGet('stats').then((res) => { stats.value = res; }); diff --git a/packages/frontend/src/pages/admin/overview.stats.vue b/packages/frontend/src/pages/admin/overview.stats.vue index 0f4707f08d38..61688c92b8c0 100644 --- a/packages/frontend/src/pages/admin/overview.stats.vue +++ b/packages/frontend/src/pages/admin/overview.stats.vue @@ -63,7 +63,7 @@ SPDX-License-Identifier: AGPL-3.0-only