refactor: tRPC 조회 입력을 JSON 본문으로 전송

브라우저의 Gateway·Game tRPC 클라이언트를 POST JSON 전송으로 통일하고 서버의 query method override를 허용한다. GET mutation 거부 계약과 production Chromium 요청 형태를 회귀 테스트로 고정한다.
This commit is contained in:
2026-08-17 11:12:02 +00:00
parent e3931602cc
commit 2d302a5f91
16 changed files with 135 additions and 20 deletions
+6 -1
View File
@@ -4,7 +4,11 @@ import fastifyStatic from '@fastify/static';
import path from 'path';
import fs from 'node:fs/promises';
import { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';
import { buildGameEventChannel, type RealtimeViewerIdentity } from '@sammo-ts/common';
import {
buildGameEventChannel,
trpcJsonBodyHttpServerOptions,
type RealtimeViewerIdentity,
} from '@sammo-ts/common';
import type { GameSessionTokenPayload } from '@sammo-ts/common/auth/gameToken';
import {
createGamePostgresConnector,
@@ -200,6 +204,7 @@ export const createGameApiServer = async () => {
prefix: config.trpcPath,
trpcOptions: {
router: appRouter,
...trpcJsonBodyHttpServerOptions,
createContext: async ({ req }: { req: FastifyRequest }) => {
const token = extractBearerToken(req.headers.authorization);
const auth = await resolveAuthFromToken(token, accessTokenStore, flushStore);
@@ -167,6 +167,26 @@ integration('game API security over HTTP transport', () => {
restoreEnv();
}, 30_000);
it('accepts an authenticated query from a POST JSON body', async () => {
const accessToken = await createAccessToken('json-query-body', {});
const general = await requestTrpc('general.me', {
method: 'POST',
input: null,
accessToken,
});
expect(general.response.status).toBe(200);
expect(general.body).toMatchObject({
result: {
data: {
general: {
id: generalId,
},
},
},
});
});
it.each([
{
label: 'global suspension',