fix(backend): 검색 결과에서 _rankingScore 제거 및 CORS 설정 추가

변경 사항:
- 검색 API 응답에서 _rankingScore 필드 제거
- @fastify/cors 패키지 추가
- docs.caadiq.co.kr에서 API 테스트 요청 허용

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
caadiq 2026-01-21 23:21:24 +09:00
parent 51063a120a
commit e136f3c74b
4 changed files with 33 additions and 5 deletions

View file

@ -9,6 +9,7 @@
"version": "2.0.0", "version": "2.0.0",
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.970.0", "@aws-sdk/client-s3": "^3.970.0",
"@fastify/cors": "^11.2.0",
"@fastify/jwt": "^10.0.0", "@fastify/jwt": "^10.0.0",
"@fastify/multipart": "^9.3.0", "@fastify/multipart": "^9.3.0",
"@fastify/static": "^8.0.0", "@fastify/static": "^8.0.0",
@ -978,6 +979,26 @@
"integrity": "sha512-m9FVDXU3GT2ITSe0UaMA5rU3QkfC/UXtCU8y0gSN/GugTqtVldOBWIB5V6V3sbmenVZUIpU6f+mPEO2+m5iTaA==", "integrity": "sha512-m9FVDXU3GT2ITSe0UaMA5rU3QkfC/UXtCU8y0gSN/GugTqtVldOBWIB5V6V3sbmenVZUIpU6f+mPEO2+m5iTaA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@fastify/cors": {
"version": "11.2.0",
"resolved": "https://registry.npmjs.org/@fastify/cors/-/cors-11.2.0.tgz",
"integrity": "sha512-LbLHBuSAdGdSFZYTLVA3+Ch2t+sA6nq3Ejc6XLAKiQ6ViS2qFnvicpj0htsx03FyYeLs04HfRNBsz/a8SvbcUw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "MIT",
"dependencies": {
"fastify-plugin": "^5.0.0",
"toad-cache": "^3.7.0"
}
},
"node_modules/@fastify/deepmerge": { "node_modules/@fastify/deepmerge": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/@fastify/deepmerge/-/deepmerge-3.1.0.tgz", "resolved": "https://registry.npmjs.org/@fastify/deepmerge/-/deepmerge-3.1.0.tgz",

View file

@ -8,6 +8,7 @@
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.970.0", "@aws-sdk/client-s3": "^3.970.0",
"@fastify/cors": "^11.2.0",
"@fastify/jwt": "^10.0.0", "@fastify/jwt": "^10.0.0",
"@fastify/multipart": "^9.3.0", "@fastify/multipart": "^9.3.0",
"@fastify/static": "^8.0.0", "@fastify/static": "^8.0.0",

View file

@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import Fastify from 'fastify'; import Fastify from 'fastify';
import fastifyCors from '@fastify/cors';
import fastifyStatic from '@fastify/static'; import fastifyStatic from '@fastify/static';
import fastifySwagger from '@fastify/swagger'; import fastifySwagger from '@fastify/swagger';
import multipart from '@fastify/multipart'; import multipart from '@fastify/multipart';
@ -34,6 +35,14 @@ export async function buildApp(opts = {}) {
// config 데코레이터 등록 // config 데코레이터 등록
fastify.decorate('config', config); fastify.decorate('config', config);
// CORS 설정 (API 문서 포털에서 테스트 요청 허용)
await fastify.register(fastifyCors, {
origin: ['https://docs.caadiq.co.kr'],
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
});
// multipart 플러그인 등록 (파일 업로드용) // multipart 플러그인 등록 (파일 업로드용)
await fastify.register(multipart, { await fastify.register(multipart, {
limits: { limits: {
@ -91,10 +100,8 @@ export async function buildApp(opts = {}) {
}, },
}); });
// OpenAPI JSON 엔드포인트 (CORS 허용 - API 문서 포털용) // OpenAPI JSON 엔드포인트
fastify.get('/docs/json', { schema: { hide: true } }, async (request, reply) => { fastify.get('/docs/json', { schema: { hide: true } }, async () => {
reply.header('Access-Control-Allow-Origin', 'https://docs.caadiq.co.kr');
reply.header('Access-Control-Allow-Methods', 'GET');
return fastify.swagger(); return fastify.swagger();
}); });

View file

@ -151,7 +151,6 @@ function formatScheduleResponse(hit) {
}, },
source, source,
members, members,
_rankingScore: hit._rankingScore,
}; };
} }