From b4f1afe4ac9e11ee135a925ca4a66a0abcdd626e Mon Sep 17 00:00:00 2001 From: lethdat Date: Thu, 2 Apr 2026 18:13:49 +0000 Subject: [PATCH] fix: update STREAM_API_GRPC_ADDR and refactor secure-json-transformer usage --- .deploy/stream.ui-production.yaml | 2 +- components.d.ts | 2 ++ src/api/rpcclient.ts | 11 ++--------- src/lib/translation/index.ts | 2 +- src/server/routes/rpc/index.ts | 10 +++++----- src/shared/secure-json-transformer.ts | 5 ++++- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.deploy/stream.ui-production.yaml b/.deploy/stream.ui-production.yaml index dfe3333..eaeddd1 100644 --- a/.deploy/stream.ui-production.yaml +++ b/.deploy/stream.ui-production.yaml @@ -7,7 +7,7 @@ metadata: labels: app: stream-ui data: - STREAM_API_GRPC_ADDR: "stream.api-svc:9000" + STREAM_API_GRPC_ADDR: "stream.api-svc" GOOGLE_AUTH_FINALIZE_PATH: "/auth/google/finalize" STREAM_INTERNAL_AUTH_MARKER: "stream_maker_123xxx" STREAM_UI_JWT_SECRET: "xxx_stream_maker_123_xxx" diff --git a/components.d.ts b/components.d.ts index 51db3fc..6f7f8d8 100644 --- a/components.d.ts +++ b/components.d.ts @@ -38,6 +38,7 @@ declare module 'vue' { CheckMarkIcon: typeof import('./src/components/icons/CheckMarkIcon.vue')['default'] ClientOnly: typeof import('./src/components/ClientOnly.tsx')['default'] CoinsIcon: typeof import('./src/components/icons/CoinsIcon.vue')['default'] + copy: typeof import('./src/components/icons/UserIcon copy.vue')['default'] Credit: typeof import('./src/components/icons/Credit.vue')['default'] CreditCardIcon: typeof import('./src/components/icons/CreditCardIcon.vue')['default'] DashboardLayout: typeof import('./src/components/DashboardLayout.vue')['default'] @@ -131,6 +132,7 @@ declare global { const CheckMarkIcon: typeof import('./src/components/icons/CheckMarkIcon.vue')['default'] const ClientOnly: typeof import('./src/components/ClientOnly.tsx')['default'] const CoinsIcon: typeof import('./src/components/icons/CoinsIcon.vue')['default'] + const copy: typeof import('./src/components/icons/UserIcon copy.vue')['default'] const Credit: typeof import('./src/components/icons/Credit.vue')['default'] const CreditCardIcon: typeof import('./src/components/icons/CreditCardIcon.vue')['default'] const DashboardLayout: typeof import('./src/components/DashboardLayout.vue')['default'] diff --git a/src/api/rpcclient.ts b/src/api/rpcclient.ts index 561b174..4b8ec16 100644 --- a/src/api/rpcclient.ts +++ b/src/api/rpcclient.ts @@ -7,9 +7,7 @@ const publicEndpoint = "/rpc-public"; const url = import.meta.env.SSR ? "http://localhost" : ""; const publicMethods = ["login", "register", "forgotPassword", "resetPassword", "getGoogleLoginUrl"]; // src/client/trpc-client-transformer.ts -import { - clientJSON -} from "@/shared/secure-json-transformer"; +import clientJSON from "@/shared/secure-json-transformer"; // export function createTrpcClientTransformer(cfg: ServerPublicKeyConfig) { @@ -26,12 +24,7 @@ export const client = proxyTinyRpc({ return await httpClientAdapter({ url: `${url}${targetEndpoint}`, pathsForGET: ["health"], - JSON: { - // parse: clientJSON.parse, - parse: (v, fn) => JSON.parse(v), - // stringify: clientJSON.stringify, - stringify: (v, fn) => JSON.stringify(v), - }, + JSON: clientJSON, headers: () => Promise.resolve({}) }).send(data); }, diff --git a/src/lib/translation/index.ts b/src/lib/translation/index.ts index 617173f..8ccb29d 100644 --- a/src/lib/translation/index.ts +++ b/src/lib/translation/index.ts @@ -2,7 +2,7 @@ import i18next from "i18next"; import I18NextHttpBackend, { HttpBackendOptions } from "i18next-http-backend"; const backendOptions: HttpBackendOptions = { - loadPath: `${process.env.FRONTEND_BASE_URL || ''}/locales/{{lng}}/{{ns}}.json`, + loadPath: `${import.meta.env.SSR ? process.env.FRONTEND_BASE_URL : ''}/locales/{{lng}}/{{ns}}.json`, request: async (_options, url, _payload, callback) => { try { diff --git a/src/server/routes/rpc/index.ts b/src/server/routes/rpc/index.ts index bcff6c1..00e2cfd 100644 --- a/src/server/routes/rpc/index.ts +++ b/src/server/routes/rpc/index.ts @@ -1,6 +1,6 @@ import { authenticate } from "@/server/middlewares/authenticate"; import { getGrpcMetadataFromContext } from "@/server/services/grpcClient"; -import { parse, stringify } from "@/shared/secure-json-transformer"; +import clientJSON from "@/shared/secure-json-transformer"; import { Metadata } from "@grpc/grpc-js"; import { exposeTinyRpc, httpServerAdapter } from "@hiogawa/tiny-rpc"; import { Hono } from "hono"; @@ -33,9 +33,9 @@ export const pathsForGET: (keyof typeof protectedRoutes)[] = ["health"]; export function registerRpcRoutes(app: Hono) { const JSONProcessor: JsonTransformer = { - parse: (v) => parse(v, () => getContext()?.req.header()), + parse: (v) => clientJSON.parse(v, () => getContext()?.req.header()), stringify: (v) => - stringify(v, (headers) => { + clientJSON.stringify(v, (headers) => { const ctx = getContext(); if (ctx) { Object.entries(headers).forEach(([k, v]) => { @@ -48,7 +48,7 @@ export function registerRpcRoutes(app: Hono) { const protectedHandler = exposeTinyRpc({ routes: protectedRoutes, adapter: httpServerAdapter({ endpoint: "/rpc", - // JSON: JSONProcessor + JSON: JSONProcessor }), }); app.use(publicEndpoint, async (c, next) => { @@ -56,7 +56,7 @@ export function registerRpcRoutes(app: Hono) { routes: publicRoutes, adapter: httpServerAdapter({ endpoint: "/rpc-public", - // JSON: JSONProcessor, + JSON: JSONProcessor, }), }); const res = await publicHandler({ request: c.req.raw }); diff --git a/src/shared/secure-json-transformer.ts b/src/shared/secure-json-transformer.ts index e098e3c..de36bf4 100644 --- a/src/shared/secure-json-transformer.ts +++ b/src/shared/secure-json-transformer.ts @@ -152,7 +152,10 @@ export function parse(d: string, getHeader?: () => Record): any const parsed = JSON.parse(utf8Decode(opened)); return superjson.deserialize(parsed); } -export const clientJSON: JsonTransformer = { +export default import.meta.env.DEV ? { + parse: (v: string, fn: any) => JSON.parse(v), + stringify: (v: any, fn: any) => JSON.stringify(v), +} : { stringify, parse, }