fix: forward query params through redirect
Build and Deploy / build-and-deploy (push) Successful in 1m38s

This commit is contained in:
2026-07-07 22:34:52 +07:00 Unverified
parent 7bfabaa5a1
commit 7dea15ef96
+4 -8
View File
@@ -486,8 +486,8 @@ export function card(app: App) {
) )
.get( .get(
"/enka/:username", "/enka/:username",
async ({ params: { username }, query: { lang } }) => { async ({ params: { username }, query }) => {
const errorLoc = cardErrorLocs[lang === "th" ? "th" : "en"]; const errorLoc = cardErrorLocs[query.lang === "th" ? "th" : "en"];
try { try {
const cacheKey = `enka-redir::${username}`; const cacheKey = `enka-redir::${username}`;
if (feature("API")) { if (feature("API")) {
@@ -540,7 +540,7 @@ export function card(app: App) {
if (!builds?.id) return status(404, errorLoc.buildNotFound); if (!builds?.id) return status(404, errorLoc.buildNotFound);
const res = redirect( const res = redirect(
`/v1/card/enka/${username}/${hoyo.hash}/${builds.char}/${builds.id}`, `/v1/card/enka/${username}/${hoyo.hash}/${builds.char}/${builds.id}${new URLSearchParams(query as Record<string, string>)}`,
); );
queueMicrotask(async () => { queueMicrotask(async () => {
cache.set(cacheKey, res, 1000 * 60); // cache for 1 minute cache.set(cacheKey, res, 1000 * 60); // cache for 1 minute
@@ -559,11 +559,7 @@ export function card(app: App) {
} }
}, },
{ {
query: t.Partial( query: characterCardQuery,
t.Object({
lang: Locale,
}),
),
}, },
) )
.get( .get(