File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,14 @@ export default async function middleware(request: Request) {
1818 ) ;
1919
2020 if ( ! response . ok ) {
21- // API 응답이 404인 경우 클라이언트 라우팅으로 처리
22- return new Response ( null , {
21+ // API 응답이 404인 경우 원본 HTML을 반환하여 클라이언트 라우팅이 처리하도록 함
22+ const res = await fetch ( new URL ( '/' , request . url ) ) ;
23+ const html = await res . text ( ) ;
24+ return new Response ( html , {
2325 status : 200 ,
26+ headers : {
27+ 'content-type' : 'text/html;charset=UTF-8' ,
28+ } ,
2429 } ) ;
2530 }
2631
@@ -71,9 +76,14 @@ export default async function middleware(request: Request) {
7176 } ,
7277 } ) ;
7378 } catch ( error ) {
74- // 에러 발생 시 클라이언트 라우팅으로 처리
75- return new Response ( null , {
79+ // 에러 발생 시 원본 HTML을 반환하여 클라이언트 라우팅이 처리하도록 함
80+ const res = await fetch ( new URL ( '/' , request . url ) ) ;
81+ const html = await res . text ( ) ;
82+ return new Response ( html , {
7683 status : 200 ,
84+ headers : {
85+ 'content-type' : 'text/html;charset=UTF-8' ,
86+ } ,
7787 } ) ;
7888 }
7989}
You can’t perform that action at this time.
0 commit comments