Skip to content

Commit e1ebc15

Browse files
committed
1 parent 92aa800 commit e1ebc15

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

backend/api/index.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
1+
// backend/api/index.ts
12
import { Hono } from 'hono';
2-
import { cors } from 'hono/cors'; // CORS 미들웨어 import
3+
import { cors } from 'hono/cors';
34

45
const app = new Hono();
56

6-
// CORS 미들웨어 설정....
7-
app.use(
8-
'/*', // 하위의 모든 경로에 CORS 적용
9-
cors({
10-
// Vercel에 배포된 프론트엔드 URL을 허용
11-
// 또는 개발 편의를 위해 일단 모든 출처를 허용할 수도 있습니다.
12-
origin: [
13-
'http://localhost:5173', // 로컬 개발용
14-
'https://cherrycoder9-github-io-frontend.vercel.app' // Vercel 배포용
15-
],
16-
allowMethods: ['GET', 'POST', 'OPTIONS'], // 허용할 HTTP 메소드
17-
allowHeaders: ['Content-Type', 'Authorization'], // 허용할 요청 헤더
18-
})
19-
);
7+
// 'cors'에 모든 옵션을 제거하여 모든 출처를 허용하도록 변경합니다.
8+
app.use('/*', cors());
9+
10+
// --- 나머지 코드는 그대로 둡니다 ---
2011

21-
// 기존 루트 핸들러 (약간 수정하여 구분)
2212
app.get('/', (c) => {
2313
return c.text('Hello Hono from the backend root!');
2414
});
2515

26-
// 새로운 API 엔드포인트 추가
2716
app.get('/greet', (c) => {
28-
console.log('✅ GET /api/greet 요청 받음'); // 백엔드 터미널에 로그 출력
17+
console.log('✅ GET /api/greet 요청 받음');
2918
const message = '안녕하세요!! Hono 백엔드에서 보내는 메시지입니다. 👋';
30-
return c.json({ message: message }); // JSON 형태로 메시지 반환
19+
return c.json({ message: message });
3120
});
3221

33-
export default app; // Vercel 배포를 위해 export default 추가
22+
export default app;

0 commit comments

Comments
 (0)