- 가격표 섹션을 페이지 하단에서 히어로 바로 아래로 이동 - 상단 패딩 축소 (py-24 → pt-12 pb-24) - 서브탭(서울/글로벌 타입) 스타일을 메인탭과 동일하게 통일 - Pages Functions API 프록시 추가 (functions/) - wrangler.toml 및 TypeScript 설정 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
/**
|
|
* Recommendation endpoint
|
|
* POST /api/recommend → Worker POST /recommend
|
|
*/
|
|
|
|
import { type PagesFunction } from '@cloudflare/workers-types';
|
|
import {
|
|
Env,
|
|
createCorsPreflightResponse,
|
|
createErrorResponse,
|
|
proxyToWorker,
|
|
} from '../_shared/proxy';
|
|
|
|
export const onRequestPost: PagesFunction<Env> = async ({ request, env }) => {
|
|
try {
|
|
// Read request body
|
|
const body = await request.text();
|
|
|
|
// Validate JSON
|
|
if (body) {
|
|
try {
|
|
JSON.parse(body);
|
|
} catch {
|
|
return createErrorResponse('Invalid JSON in request body', 400);
|
|
}
|
|
}
|
|
|
|
return proxyToWorker(env, '/recommend', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body,
|
|
});
|
|
} catch (error) {
|
|
console.error('[Recommend] Failed to process request:', error);
|
|
return createErrorResponse(
|
|
'Failed to process recommendation request',
|
|
500,
|
|
error instanceof Error ? error.message : String(error)
|
|
);
|
|
}
|
|
};
|
|
|
|
export const onRequestOptions: PagesFunction<Env> = async () => {
|
|
return createCorsPreflightResponse();
|
|
};
|