(handleIndex: number)
| 369 | } |
| 370 | |
| 371 | const handleRequest = async (handleIndex: number) => { |
| 372 | if (handleIndex > 5) { |
| 373 | throw new Error(`Attempted to handle request too many times ${req.url}`) |
| 374 | } |
| 375 | |
| 376 | // handle hot-reloader first |
| 377 | if (development) { |
| 378 | if ( |
| 379 | blockCrossSiteDEV( |
| 380 | req, |
| 381 | res, |
| 382 | development.config.allowedDevOrigins, |
| 383 | opts.hostname |
| 384 | ) |
| 385 | ) { |
| 386 | return |
| 387 | } |
| 388 | |
| 389 | const origUrl = req.url || '/' |
| 390 | |
| 391 | // both the basePath and assetPrefix need to be stripped from the URL |
| 392 | // so that the development bundler can find the correct file |
| 393 | if (config.basePath && pathHasPrefix(origUrl, config.basePath)) { |
| 394 | req.url = removePathPrefix(origUrl, config.basePath) |
| 395 | } else if ( |
| 396 | config.assetPrefix && |
| 397 | pathHasPrefix(origUrl, config.assetPrefix) |
| 398 | ) { |
| 399 | req.url = removePathPrefix(origUrl, config.assetPrefix) |
| 400 | } |
| 401 | |
| 402 | const parsedUrl = parseUrlUtil(req.url || '/') |
| 403 | |
| 404 | const hotReloaderResult = await development.bundler.hotReloader.run( |
| 405 | req, |
| 406 | res, |
| 407 | parsedUrl |
| 408 | ) |
| 409 | |
| 410 | if (hotReloaderResult.finished) { |
| 411 | return hotReloaderResult |
| 412 | } |
| 413 | |
| 414 | req.url = origUrl |
| 415 | } |
| 416 | |
| 417 | const { |
| 418 | finished, |
| 419 | parsedUrl, |
| 420 | statusCode, |
| 421 | resHeaders, |
| 422 | bodyStream, |
| 423 | matchedOutput, |
| 424 | } = await resolveRoutes({ |
| 425 | req, |
| 426 | res, |
| 427 | isUpgradeReq: false, |
| 428 | signal: signalFromNodeResponse(res), |
no test coverage detected
searching dependent graphs…