fix: update STREAM_API_GRPC_ADDR and refactor secure-json-transformer usage

This commit is contained in:
2026-04-02 18:13:49 +00:00
parent 57b4016021
commit b4f1afe4ac
6 changed files with 15 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ metadata:
labels: labels:
app: stream-ui app: stream-ui
data: data:
STREAM_API_GRPC_ADDR: "stream.api-svc:9000" STREAM_API_GRPC_ADDR: "stream.api-svc"
GOOGLE_AUTH_FINALIZE_PATH: "/auth/google/finalize" GOOGLE_AUTH_FINALIZE_PATH: "/auth/google/finalize"
STREAM_INTERNAL_AUTH_MARKER: "stream_maker_123xxx" STREAM_INTERNAL_AUTH_MARKER: "stream_maker_123xxx"
STREAM_UI_JWT_SECRET: "xxx_stream_maker_123_xxx" STREAM_UI_JWT_SECRET: "xxx_stream_maker_123_xxx"

2
components.d.ts vendored
View File

@@ -38,6 +38,7 @@ declare module 'vue' {
CheckMarkIcon: typeof import('./src/components/icons/CheckMarkIcon.vue')['default'] CheckMarkIcon: typeof import('./src/components/icons/CheckMarkIcon.vue')['default']
ClientOnly: typeof import('./src/components/ClientOnly.tsx')['default'] ClientOnly: typeof import('./src/components/ClientOnly.tsx')['default']
CoinsIcon: typeof import('./src/components/icons/CoinsIcon.vue')['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'] Credit: typeof import('./src/components/icons/Credit.vue')['default']
CreditCardIcon: typeof import('./src/components/icons/CreditCardIcon.vue')['default'] CreditCardIcon: typeof import('./src/components/icons/CreditCardIcon.vue')['default']
DashboardLayout: typeof import('./src/components/DashboardLayout.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 CheckMarkIcon: typeof import('./src/components/icons/CheckMarkIcon.vue')['default']
const ClientOnly: typeof import('./src/components/ClientOnly.tsx')['default'] const ClientOnly: typeof import('./src/components/ClientOnly.tsx')['default']
const CoinsIcon: typeof import('./src/components/icons/CoinsIcon.vue')['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 Credit: typeof import('./src/components/icons/Credit.vue')['default']
const CreditCardIcon: typeof import('./src/components/icons/CreditCardIcon.vue')['default'] const CreditCardIcon: typeof import('./src/components/icons/CreditCardIcon.vue')['default']
const DashboardLayout: typeof import('./src/components/DashboardLayout.vue')['default'] const DashboardLayout: typeof import('./src/components/DashboardLayout.vue')['default']

View File

@@ -7,9 +7,7 @@ const publicEndpoint = "/rpc-public";
const url = import.meta.env.SSR ? "http://localhost" : ""; const url = import.meta.env.SSR ? "http://localhost" : "";
const publicMethods = ["login", "register", "forgotPassword", "resetPassword", "getGoogleLoginUrl"]; const publicMethods = ["login", "register", "forgotPassword", "resetPassword", "getGoogleLoginUrl"];
// src/client/trpc-client-transformer.ts // src/client/trpc-client-transformer.ts
import { import clientJSON from "@/shared/secure-json-transformer";
clientJSON
} from "@/shared/secure-json-transformer";
// export function createTrpcClientTransformer(cfg: ServerPublicKeyConfig) { // export function createTrpcClientTransformer(cfg: ServerPublicKeyConfig) {
@@ -26,12 +24,7 @@ export const client = proxyTinyRpc<RpcRoutes>({
return await httpClientAdapter({ return await httpClientAdapter({
url: `${url}${targetEndpoint}`, url: `${url}${targetEndpoint}`,
pathsForGET: ["health"], pathsForGET: ["health"],
JSON: { JSON: clientJSON,
// parse: clientJSON.parse,
parse: (v, fn) => JSON.parse(v),
// stringify: clientJSON.stringify,
stringify: (v, fn) => JSON.stringify(v),
},
headers: () => Promise.resolve({}) headers: () => Promise.resolve({})
}).send(data); }).send(data);
}, },

View File

@@ -2,7 +2,7 @@ import i18next from "i18next";
import I18NextHttpBackend, { HttpBackendOptions } from "i18next-http-backend"; import I18NextHttpBackend, { HttpBackendOptions } from "i18next-http-backend";
const backendOptions: HttpBackendOptions = { 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) => { request: async (_options, url, _payload, callback) => {
try { try {

View File

@@ -1,6 +1,6 @@
import { authenticate } from "@/server/middlewares/authenticate"; import { authenticate } from "@/server/middlewares/authenticate";
import { getGrpcMetadataFromContext } from "@/server/services/grpcClient"; 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 { Metadata } from "@grpc/grpc-js";
import { exposeTinyRpc, httpServerAdapter } from "@hiogawa/tiny-rpc"; import { exposeTinyRpc, httpServerAdapter } from "@hiogawa/tiny-rpc";
import { Hono } from "hono"; import { Hono } from "hono";
@@ -33,9 +33,9 @@ export const pathsForGET: (keyof typeof protectedRoutes)[] = ["health"];
export function registerRpcRoutes(app: Hono) { export function registerRpcRoutes(app: Hono) {
const JSONProcessor: JsonTransformer = { const JSONProcessor: JsonTransformer = {
parse: (v) => parse(v, () => getContext()?.req.header()), parse: (v) => clientJSON.parse(v, () => getContext()?.req.header()),
stringify: (v) => stringify: (v) =>
stringify(v, (headers) => { clientJSON.stringify(v, (headers) => {
const ctx = getContext(); const ctx = getContext();
if (ctx) { if (ctx) {
Object.entries(headers).forEach(([k, v]) => { Object.entries(headers).forEach(([k, v]) => {
@@ -48,7 +48,7 @@ export function registerRpcRoutes(app: Hono) {
const protectedHandler = exposeTinyRpc({ const protectedHandler = exposeTinyRpc({
routes: protectedRoutes, routes: protectedRoutes,
adapter: httpServerAdapter({ endpoint: "/rpc", adapter: httpServerAdapter({ endpoint: "/rpc",
// JSON: JSONProcessor JSON: JSONProcessor
}), }),
}); });
app.use(publicEndpoint, async (c, next) => { app.use(publicEndpoint, async (c, next) => {
@@ -56,7 +56,7 @@ export function registerRpcRoutes(app: Hono) {
routes: publicRoutes, routes: publicRoutes,
adapter: httpServerAdapter({ adapter: httpServerAdapter({
endpoint: "/rpc-public", endpoint: "/rpc-public",
// JSON: JSONProcessor, JSON: JSONProcessor,
}), }),
}); });
const res = await publicHandler({ request: c.req.raw }); const res = await publicHandler({ request: c.req.raw });

View File

@@ -152,7 +152,10 @@ export function parse(d: string, getHeader?: () => Record<string, string>): any
const parsed = JSON.parse(utf8Decode(opened)); const parsed = JSON.parse(utf8Decode(opened));
return superjson.deserialize(parsed); 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, stringify,
parse, parse,
} }