diff --git a/packages/next/src/server/base-server.ts b/packages/next/src/server/base-server.ts index 3391c0ca2dc95..41df0192ae9dc 100644 --- a/packages/next/src/server/base-server.ts +++ b/packages/next/src/server/base-server.ts @@ -3119,10 +3119,7 @@ export default abstract class Server< isRoutePPREnabled ) { revalidate = 0 - } else if ( - typeof cacheEntry.revalidate !== 'undefined' && - (!this.renderOpts.dev || (hasServerProps && !isNextDataRequest)) - ) { + } else if (!this.renderOpts.dev || (hasServerProps && !isNextDataRequest)) { // If this is a preview mode request, we shouldn't cache it if (isPreviewMode) { revalidate = 0 diff --git a/test/e2e/app-dir/app/index.test.ts b/test/e2e/app-dir/app/index.test.ts index 89412657ce973..0a9c597ee3b8e 100644 --- a/test/e2e/app-dir/app/index.test.ts +++ b/test/e2e/app-dir/app/index.test.ts @@ -20,6 +20,18 @@ describe('app dir - basic', () => { }, }) + if (isNextStart) { + it('should have correct cache-control for SSR routes', async () => { + for (const path of ['/catch-all/first', '/ssr']) { + const res = await next.fetch(path) + expect(res.status).toBe(200) + expect(res.headers.get('Cache-Control')).toBe( + 'private, no-cache, no-store, max-age=0, must-revalidate' + ) + } + }) + } + if (process.env.NEXT_EXPERIMENTAL_COMPILE) { it('should provide query for getStaticProps page correctly', async () => { const res = await next.fetch('/ssg?hello=world') diff --git a/test/e2e/app-dir/app/pages/ssr.js b/test/e2e/app-dir/app/pages/ssr.js new file mode 100644 index 0000000000000..5f554b1f32a3d --- /dev/null +++ b/test/e2e/app-dir/app/pages/ssr.js @@ -0,0 +1,16 @@ +import { useRouter } from 'next/router' + +export default function Page(props) { + return ( + <> +

hello from ssr

+

{JSON.stringify(useRouter().query)}

+ + ) +} + +export function getServerSideProps() { + return { + props: {}, + } +}