@@ -7,7 +7,6 @@ export default async function middleware(request: Request) {
77 const memeId = url . pathname . split ( '/' ) . pop ( ) ;
88
99 try {
10- // API에서 밈 데이터를 가져옵니다
1110 const response = await fetch (
1211 `https://api.meme-wiki.net/api/memes/${ memeId } ` ,
1312 {
@@ -18,7 +17,6 @@ export default async function middleware(request: Request) {
1817 ) ;
1918
2019 if ( ! response . ok ) {
21- // API 응답이 404인 경우 원본 HTML을 반환하여 클라이언트 라우팅이 처리하도록 함
2220 const res = await fetch ( new URL ( '/' , request . url ) ) ;
2321 const html = await res . text ( ) ;
2422 return new Response ( html , {
@@ -31,11 +29,9 @@ export default async function middleware(request: Request) {
3129
3230 const data = await response . json ( ) ;
3331
34- // 원본 HTML을 가져옵니다
3532 const res = await fetch ( new URL ( '/' , request . url ) ) ;
3633 const html = await res . text ( ) ;
3734
38- // OG 태그를 동적으로 교체합니다
3935 const modifiedHtml = html
4036 . replace (
4137 / < m e t a \s + p r o p e r t y = " o g : t i t l e " \s + c o n t e n t = " [ ^ " ] * " [ ^ > ] * > / ,
@@ -76,7 +72,6 @@ export default async function middleware(request: Request) {
7672 } ,
7773 } ) ;
7874 } catch ( error ) {
79- // 에러 발생 시 원본 HTML을 반환하여 클라이언트 라우팅이 처리하도록 함
8075 const res = await fetch ( new URL ( '/' , request . url ) ) ;
8176 const html = await res . text ( ) ;
8277 return new Response ( html , {
0 commit comments