// This method mimics what the version of `send` we use does:
// 1. decodeURIComponent:
...
...
@@ -2655,21 +2560,6 @@ export default abstract class Server {
returnfilesystemUrls.has(resolved)
}
protectedreadBuildId():string{
constbuildIdFile=join(this.distDir,BUILD_ID_FILE)
try{
returnfs.readFileSync(buildIdFile,'utf8').trim()
}catch(err){
if(!fs.existsSync(buildIdFile)){
thrownewError(
`Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id`
`Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id`
)
}
throwerr
}
}
protectedgeneratePublicRoutes():Route[]{
if(!fs.existsSync(this.publicDir))return[]
constpublicFiles=newSet(
recursiveReadDirSync(this.publicDir).map((p)=>
encodeURI(p.replace(/\\/g,'/'))
)
)
return[
{
match:route('/:path*'),
name:'public folder catchall',
fn:async(req,res,params,parsedUrl)=>{
constpathParts:string[]=params.path||[]
const{basePath}=this.nextConfig
// if basePath is defined require it be present
if(basePath){
constbasePathParts=basePath.split('/')
// remove first empty value
basePathParts.shift()
if(
!basePathParts.every((part:string,idx:number)=>{
returnpart===pathParts[idx]
})
){
return{finished:false}
}
pathParts.splice(0,basePathParts.length)
}
letpath=`/${pathParts.join('/')}`
if(!publicFiles.has(path)){
// In `next-dev-server.ts`, we ensure encoded paths match
// decoded paths on the filesystem. So we need do the
// opposite here: make sure decoded paths match encoded.