Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure etags are not generated for static files when disabled #55376

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/next/src/server/lib/router-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ export async function initialize(opts: {
try {
return await serveStatic(req, res, matchedOutput.itemPath, {
root: matchedOutput.itemsRoot,
// Ensures that etags are not generated for static files when disabled.
etag: config.generateEtags,
})
} catch (err: any) {
/**
Expand Down
10 changes: 8 additions & 2 deletions packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function getMiddlewareMatcher(
}

export default class NextNodeServer extends BaseServer {
private _serverDistDir: string | undefined
private imageResponseCache?: ResponseCache
protected renderWorkersPromises?: Promise<void>
protected renderWorkerOpts?: Parameters<
Expand Down Expand Up @@ -1886,8 +1887,13 @@ export default class NextNodeServer extends BaseServer {
return result
}

protected get serverDistDir() {
return join(this.distDir, SERVER_DIRECTORY)
protected get serverDistDir(): string {
if (this._serverDistDir) {
return this._serverDistDir
}
const serverDistDir = join(this.distDir, SERVER_DIRECTORY)
this._serverDistDir = serverDistDir
return serverDistDir
}

protected async getFallbackErrorComponents(): Promise<LoadComponentsReturnType | null> {
Expand Down