From d42f7bce5be416569a29128a7e4db67279566a7c Mon Sep 17 00:00:00 2001 From: bytedream Date: Thu, 29 Oct 2026 18:35:23 +0100 Subject: [PATCH] update all invalid occurences of BASE_PATH --- astro.config.mjs | 1 + flake.nix | 1 + src/db/schema/directSignup.ts | 4 ++-- src/db/schema/report.ts | 4 ++-- src/pages/api/feedback/index.ts | 4 ++-- src/pages/api/reports/index.ts | 4 ++-- src/pages/api/users/[...uuid]/reports.ts | 6 +++--- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index be33af0..64ea0ae 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -52,6 +52,7 @@ export default defineConfig({ DATABASE_URI: envField.string({ context: 'server', access: 'secret' }), + BASE_HOST: envField.string({ context: 'server', access: 'secret', default: 'http://localhost:4321' }), BASE_PATH: envField.string({ context: 'server', access: 'secret', default: '/' }) } }, diff --git a/flake.nix b/flake.nix index 309fdc5..7fbd410 100644 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,7 @@ PAYPAL_LINK = "http://example.com"; SERVER_IP = "example.com"; + BASE_HOST = "http://localhost:4321"; BASE_PATH = "/craftattack"; }; diff --git a/src/db/schema/directSignup.ts b/src/db/schema/directSignup.ts index 919f6aa..5833521 100644 --- a/src/db/schema/directSignup.ts +++ b/src/db/schema/directSignup.ts @@ -3,7 +3,7 @@ import { int, mysqlTable, varchar } from 'drizzle-orm/mysql-core'; import { user } from '@db/schema/user.ts'; import { eq } from 'drizzle-orm'; import { generateRandomString } from '@util/random.ts'; -import { BASE_PATH } from 'astro:env/server'; +import { BASE_HOST, BASE_PATH } from 'astro:env/server'; type Database = MySql2Database<{ directSignup: typeof directSignup }>; @@ -36,7 +36,7 @@ export async function addDirectSignup(db: Database, _values: AddDirectSignupReq) hash: hash }); - return { hash: hash, url: `${BASE_PATH}/signup/${hash}` }; + return { hash: hash, url: `${BASE_HOST}/${BASE_PATH}/signup/${hash}` }; } export async function setDirectSignupUser(db: Database, values: SetDirectSignupUserReq) { diff --git a/src/db/schema/report.ts b/src/db/schema/report.ts index 4bcbb58..40d3fa4 100644 --- a/src/db/schema/report.ts +++ b/src/db/schema/report.ts @@ -3,7 +3,7 @@ import type { MySql2Database } from 'drizzle-orm/mysql2'; import { and, desc, eq, isNotNull, like } from 'drizzle-orm'; import { reportStatus } from './reportStatus.ts'; import { generateRandomString } from '@util/random.ts'; -import { BASE_PATH } from 'astro:env/server'; +import { BASE_HOST, BASE_PATH } from 'astro:env/server'; import { strikeReason } from '@db/schema/strikeReason.ts'; import { strike } from '@db/schema/strike.ts'; import { user } from '@db/schema/user.ts'; @@ -70,7 +70,7 @@ export async function addReport(db: Database, values: AddReportReq) { }) .$returningId(); - return Object.assign(r[0], { url: `${BASE_PATH}/report/${urlHash}` }); + return Object.assign(r[0], { url: `${BASE_HOST}/${BASE_PATH}/report/${urlHash}` }); } export async function editReport(db: Database, values: EditReportReq) { diff --git a/src/pages/api/feedback/index.ts b/src/pages/api/feedback/index.ts index 80ca3b3..67c2bfb 100644 --- a/src/pages/api/feedback/index.ts +++ b/src/pages/api/feedback/index.ts @@ -1,7 +1,7 @@ import { externalApi } from '../_api.ts'; import { z } from 'astro:schema'; import { db } from '@db/database.ts'; -import { BASE_PATH } from 'astro:env/server'; +import { BASE_HOST, BASE_PATH } from 'astro:env/server'; export const POST = externalApi({ input: z.object({ @@ -19,7 +19,7 @@ export const POST = externalApi({ const response = feedbacks.map((feedback) => ({ uuid: feedback.uuid, - url: `${BASE_PATH}/feedback/${feedback.urlHash}` + url: `${BASE_HOST}/${BASE_PATH}/feedback/${feedback.urlHash}` })); return new Response(JSON.stringify({ feedback: response }), { status: 200 }); diff --git a/src/pages/api/reports/index.ts b/src/pages/api/reports/index.ts index 1bde0b6..6bce3b1 100644 --- a/src/pages/api/reports/index.ts +++ b/src/pages/api/reports/index.ts @@ -2,7 +2,7 @@ import { externalApi } from '../_api.ts'; import { z } from 'astro:schema'; import { db } from '@db/database.ts'; import { sendWebhook, WebhookAction } from '@util/webhook.ts'; -import { BASE_PATH } from 'astro:env/server'; +import { BASE_HOST, BASE_PATH } from 'astro:env/server'; export const GET = externalApi({ auth: true, @@ -17,7 +17,7 @@ export const GET = externalApi({ reason: report.reason, created: report.createdAt?.getTime() ?? null, status: report.status?.status ?? null, - url: `${BASE_PATH}/report/${report.urlHash}` + url: `${BASE_HOST}/${BASE_PATH}/report/${report.urlHash}` })) }), { status: 200 } diff --git a/src/pages/api/users/[...uuid]/reports.ts b/src/pages/api/users/[...uuid]/reports.ts index 0c25e55..d6d4f37 100644 --- a/src/pages/api/users/[...uuid]/reports.ts +++ b/src/pages/api/users/[...uuid]/reports.ts @@ -1,6 +1,6 @@ import { externalApi } from '../../_api.ts'; import { db } from '@db/database.ts'; -import { BASE_PATH } from 'astro:env/server'; +import { BASE_HOST, BASE_PATH } from 'astro:env/server'; export const GET = externalApi({ auth: true, @@ -18,14 +18,14 @@ export const GET = externalApi({ reason: report.reason, created: report.createdAt?.getTime() ?? null, status: report.status?.status ?? null, - url: `${BASE_PATH}/report/${report.urlHash}` + url: `${BASE_HOST}/${BASE_PATH}/report/${report.urlHash}` })), to_self: toSelf.map((report) => ({ reporter: report.reporter?.uuid ?? null, reason: report.reason, created: report.createdAt?.getTime() ?? null, status: report.status?.status ?? null, - url: `${BASE_PATH}/report/${report.urlHash}` + url: `${BASE_HOST}/${BASE_PATH}/report/${report.urlHash}` })) }), { status: 200 }