File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11import * as HTTP from 'node:http'
22import * as Fs from 'node:fs'
3+ import * as Process from 'node:process'
34import * as Path from 'node:path'
45
56function IsLoopBack ( IP : string ) {
@@ -8,10 +9,13 @@ function IsLoopBack(IP: string) {
89
910export function RunDebugServer ( Port : number , FileName : string [ ] , ShouldPreventHTTPResponse : boolean ) {
1011 const HTTPServer = HTTP . createServer ( ( Req , Res ) => {
11- const DistRoot = Path . resolve ( process . cwd ( ) , 'dist' )
12+ let ProjectRoot = Process . cwd ( )
13+ if ( Process . cwd ( ) . endsWith ( '/builder' ) ) {
14+ ProjectRoot = Process . cwd ( ) + '/..'
15+ }
1216 const RequestPath = Req . url ?. substring ( 1 ) || ''
13- const ResolvedPath = Path . resolve ( DistRoot , RequestPath )
14- const RelativePath = Path . relative ( DistRoot , ResolvedPath )
17+ const ResolvedPath = Path . resolve ( ProjectRoot + '/dist' , RequestPath )
18+ const RelativePath = Path . relative ( ProjectRoot + '/dist' , ResolvedPath )
1519
1620 // Ensure the resolved path stays within the dist root to prevent directory traversal
1721 if ( RelativePath . startsWith ( '..' ) || Path . isAbsolute ( RelativePath ) ) {
You can’t perform that action at this time.
0 commit comments