File tree Expand file tree Collapse file tree 1 file changed +9
-20
lines changed Expand file tree Collapse file tree 1 file changed +9
-20
lines changed Original file line number Diff line number Diff line change
1
+ // backend/api/index.ts
1
2
import { Hono } from 'hono' ;
2
- import { cors } from 'hono/cors' ; // CORS 미들웨어 import
3
+ import { cors } from 'hono/cors' ;
3
4
4
5
const app = new Hono ( ) ;
5
6
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
+ // --- 나머지 코드는 그대로 둡니다 ---
20
11
21
- // 기존 루트 핸들러 (약간 수정하여 구분)
22
12
app . get ( '/' , ( c ) => {
23
13
return c . text ( 'Hello Hono from the backend root!' ) ;
24
14
} ) ;
25
15
26
- // 새로운 API 엔드포인트 추가
27
16
app . get ( '/greet' , ( c ) => {
28
- console . log ( '✅ GET /api/greet 요청 받음' ) ; // 백엔드 터미널에 로그 출력
17
+ console . log ( '✅ GET /api/greet 요청 받음' ) ;
29
18
const message = '안녕하세요!! Hono 백엔드에서 보내는 메시지입니다. 👋' ;
30
- return c . json ( { message : message } ) ; // JSON 형태로 메시지 반환
19
+ return c . json ( { message : message } ) ;
31
20
} ) ;
32
21
33
- export default app ; // Vercel 배포를 위해 export default 추가
22
+ export default app ;
You can’t perform that action at this time.
0 commit comments