From c6fabd0452fdd28d2be2745989b0ba34162bc758 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Fri, 28 Nov 2025 00:17:46 +0300 Subject: [PATCH 1/3] fix custom responses --- app/components/token/ResponseSettingsCard.vue | 8 ++++++-- server/api/token/[token]/index.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/components/token/ResponseSettingsCard.vue b/app/components/token/ResponseSettingsCard.vue index 72ac47f..ec1ca35 100644 --- a/app/components/token/ResponseSettingsCard.vue +++ b/app/components/token/ResponseSettingsCard.vue @@ -81,6 +81,7 @@ const responseEnabled = ref(false) const responseStatus = ref('200') const responseHeadersText = ref('') const responseBody = ref('') +const isFormInitialized = ref(false) const statusSummary = computed(() => { const statusLabel = responseStatus.value?.trim().length ? responseStatus.value : '200' @@ -119,14 +120,17 @@ const textToHeaders = (input: string): Record | null => { return Object.keys(out).length ? out : null } -// Watch for token data changes and update form +// Watch for token data changes and update form only on initial load watch(tokenData, (data) => { - if (!data) return + if (!data || isFormInitialized.value) { + return + } responseEnabled.value = Boolean(data.responseEnabled) responseStatus.value = String(data.responseStatus ?? 200) responseHeadersText.value = headersToText(data.responseHeaders as Record | null) responseBody.value = data.responseBody ?? '' + isFormInitialized.value = true }, { immediate: true }) const handleToggleEnabled = async (enabled: boolean | 'indeterminate') => { diff --git a/server/api/token/[token]/index.ts b/server/api/token/[token]/index.ts index 8a001c2..c66f23a 100644 --- a/server/api/token/[token]/index.ts +++ b/server/api/token/[token]/index.ts @@ -34,13 +34,13 @@ export default defineEventHandler(async (event: H3Event) => const payload = body as Record const enabled = Boolean(payload.responseEnabled) const status = Number(payload.responseStatus ?? 200) - const headers = (payload.responseHeaders as unknown) as Record | null + const headers = (payload.responseHeaders as unknown) as string | null const responseBody = (payload.responseBody as unknown) as string | null await db.tokens.update(sessionId, tokenId, { responseEnabled: enabled, responseStatus: status, - responseHeaders: headers ? JSON.stringify(headers) : null, + responseHeaders: headers, responseBody, }) From 8feddbee710cb52e677efa18c1c7e6a7facd9a2f Mon Sep 17 00:00:00 2001 From: arabcoders Date: Fri, 28 Nov 2025 00:34:26 +0300 Subject: [PATCH 2/3] fixes --- app/components/token/ResponseSettingsCard.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/token/ResponseSettingsCard.vue b/app/components/token/ResponseSettingsCard.vue index ec1ca35..9088855 100644 --- a/app/components/token/ResponseSettingsCard.vue +++ b/app/components/token/ResponseSettingsCard.vue @@ -30,7 +30,7 @@ - From f2c5e3dd7db138655dd59e07587a8b78a0c7b78b Mon Sep 17 00:00:00 2001 From: arabcoders Date: Fri, 28 Nov 2025 00:55:31 +0300 Subject: [PATCH 3/3] fix --- app/components/token/ResponseSettingsCard.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/token/ResponseSettingsCard.vue b/app/components/token/ResponseSettingsCard.vue index 9088855..87d3a48 100644 --- a/app/components/token/ResponseSettingsCard.vue +++ b/app/components/token/ResponseSettingsCard.vue @@ -84,7 +84,10 @@ const responseBody = ref('') const isFormInitialized = ref(false) const statusSummary = computed(() => { - const statusLabel = responseStatus.value?.trim().length ? responseStatus.value : '200' + let statusLabel = '200'; + if (!responseStatus.value) { + statusLabel = responseStatus.value?.trim().length ? responseStatus.value : '200' + } return responseEnabled.value ? `Custom response enabled ยท ${statusLabel}` : 'Custom responses disabled' })