@@ -174,6 +174,7 @@ export async function run(req: Request, ctx: Helix.UniversalContext): Promise<Re
174174 }
175175 log . debug ( ` contentUrl: ${ contentUrl } ` ) ;
176176 const res = await fetch ( contentUrl ) ;
177+ const lastModified = res . headers . get ( 'last-modified' ) ;
177178 if ( ! res . ok ) {
178179 const status = res . status < 500 ? res . status : 500 ;
179180 return new Response ( '' , {
@@ -281,16 +282,21 @@ export async function run(req: Request, ctx: Helix.UniversalContext): Promise<Re
281282
282283 const html = md2markup ( ctx ) ;
283284
285+ const responseHeaders : Record < string , string > = [ '127.0.0.1' , 'localhost' ] . includes ( hostname ) ? {
286+ 'content-type' : 'text/html' ,
287+ 'Access-Control-Allow-Origin' : 'http://localhost:3000' ,
288+ 'Access-Control-Allow-Methods' : 'GET, POST, OPTIONS' ,
289+ 'Access-Control-Allow-Headers' : 'Content-Type, Authorization' ,
290+ } : {
291+ 'content-type' : 'text/html' ,
292+ } ;
293+ if ( lastModified ) {
294+ responseHeaders [ 'last-modified' ] = lastModified ;
295+ }
296+
284297 return new Response ( html , {
285298 status : 200 ,
286- headers : [ '127.0.0.1' , 'localhost' ] . includes ( hostname ) ? {
287- 'content-type' : 'text/html' ,
288- 'Access-Control-Allow-Origin' : 'http://localhost:3000' ,
289- 'Access-Control-Allow-Methods' : 'GET, POST, OPTIONS' ,
290- 'Access-Control-Allow-Headers' : 'Content-Type, Authorization' ,
291- } : {
292- 'content-type' : 'text/html' ,
293- } ,
299+ headers : responseHeaders ,
294300 } ) ;
295301}
296302
0 commit comments