File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,16 +57,18 @@ const createServer = (domain = process.env["HOST"] || "localhost"): HttpsLocalho
5757 const p404 = staticPath + "/404.html"
5858 const index = staticPath + "/index.html"
5959 const fallback = fs . existsSync ( p404 )
60- ? { status : 404 , file : path . resolve ( p404 ) }
60+ ? { status : 404 , content : fs . readFileSync ( path . resolve ( p404 ) ) }
6161 : fs . existsSync ( index )
62- ? { status : 200 , file : path . resolve ( index ) }
62+ ? { status : 200 , content : fs . readFileSync ( path . resolve ( index ) ) }
6363 : undefined
6464
6565 app . use ( express . static ( staticPath ) )
66- // codeql[js/missing-rate-limiting]
6766 app . use ( ( _req : Request , res : Response ) => {
68- if ( fallback ) res . status ( fallback . status ) . sendFile ( fallback . file )
69- else res . status ( 404 ) . send ( "Not found." )
67+ if ( fallback ) {
68+ res . status ( fallback . status ) . type ( "html" ) . send ( fallback . content )
69+ } else {
70+ res . status ( 404 ) . send ( "Not found." )
71+ }
7072 } )
7173 console . info ( "Serving static path: " + staticPath )
7274 void app . listen ( port )
You can’t perform that action at this time.
0 commit comments