diff --git a/tests/fixtures/dist-dir/app/api/headers/route.js b/tests/fixtures/dist-dir/app/api/headers/route.js index 5c50b53fdb..426bfd71c8 100644 --- a/tests/fixtures/dist-dir/app/api/headers/route.js +++ b/tests/fixtures/dist-dir/app/api/headers/route.js @@ -1,14 +1,15 @@ import { cookies } from 'next/headers' export const GET = async () => { - cookies().set('foo', 'foo1') - cookies().set('bar', 'bar1') + const localCookies = await cookies() + localCookies.set('foo', 'foo1') + localCookies.set('bar', 'bar1') // Key, value, options - cookies().set('test1', 'value1', { secure: true }) + localCookies.set('test1', 'value1', { secure: true }) // One object - cookies().set({ + localCookies.set({ name: 'test2', value: 'value2', httpOnly: true, diff --git a/tests/fixtures/middleware-src/src/app/test/next/page.js b/tests/fixtures/middleware-src/src/app/test/next/page.js index 0908c69938..64e3cee782 100644 --- a/tests/fixtures/middleware-src/src/app/test/next/page.js +++ b/tests/fixtures/middleware-src/src/app/test/next/page.js @@ -1,7 +1,7 @@ import { headers } from 'next/headers' -export default function Page() { - const headersList = headers() +export default async function Page() { + const headersList = await headers() const message = headersList.get('x-hello-from-middleware-req') return ( diff --git a/tests/fixtures/middleware-trailing-slash/app/test/next/page.js b/tests/fixtures/middleware-trailing-slash/app/test/next/page.js index 0908c69938..64e3cee782 100644 --- a/tests/fixtures/middleware-trailing-slash/app/test/next/page.js +++ b/tests/fixtures/middleware-trailing-slash/app/test/next/page.js @@ -1,7 +1,7 @@ import { headers } from 'next/headers' -export default function Page() { - const headersList = headers() +export default async function Page() { + const headersList = await headers() const message = headersList.get('x-hello-from-middleware-req') return ( diff --git a/tests/fixtures/middleware/app/test/next/page.js b/tests/fixtures/middleware/app/test/next/page.js index 0908c69938..64e3cee782 100644 --- a/tests/fixtures/middleware/app/test/next/page.js +++ b/tests/fixtures/middleware/app/test/next/page.js @@ -1,7 +1,7 @@ import { headers } from 'next/headers' -export default function Page() { - const headersList = headers() +export default async function Page() { + const headersList = await headers() const message = headersList.get('x-hello-from-middleware-req') return ( diff --git a/tests/fixtures/nx-integrated/apps/custom-dist-dir/app/api/headers/route.js b/tests/fixtures/nx-integrated/apps/custom-dist-dir/app/api/headers/route.js index 025b97fb41..d295470899 100644 --- a/tests/fixtures/nx-integrated/apps/custom-dist-dir/app/api/headers/route.js +++ b/tests/fixtures/nx-integrated/apps/custom-dist-dir/app/api/headers/route.js @@ -1,14 +1,15 @@ import { cookies } from 'next/headers' export const GET = async () => { - cookies().set('foo', 'foo1') - cookies().set('bar', 'bar1') + const localCookies = await cookies() + localCookies.set('foo', 'foo1') + localCookies.set('bar', 'bar1') // Key, value, options - cookies().set('test1', 'value1', { secure: true }) + localCookies.set('test1', 'value1', { secure: true }) // One object - cookies().set({ + localCookies.set({ name: 'test2', value: 'value2', httpOnly: true, @@ -23,4 +24,4 @@ export const GET = async () => { ['Set-Cookie', 'baz=baz2'], ], }) -} \ No newline at end of file +} diff --git a/tests/fixtures/revalidate-fetch/app/dynamic-posts/[id]/page.js b/tests/fixtures/revalidate-fetch/app/dynamic-posts/[id]/page.js index 87d878b4a2..2faef69874 100644 --- a/tests/fixtures/revalidate-fetch/app/dynamic-posts/[id]/page.js +++ b/tests/fixtures/revalidate-fetch/app/dynamic-posts/[id]/page.js @@ -9,7 +9,8 @@ async function getData(params) { } export default async function Page({ params }) { - const data = await getData(params) + const { id } = await params + const data = await getData({ id }) return ( <> @@ -19,7 +20,7 @@ export default async function Page({ params }) {
Show
{data.name}
Param
-
{params.id}
+
{id}
Time
{Date.now()}
Time from fetch response
diff --git a/tests/fixtures/revalidate-fetch/app/posts/[id]/page.js b/tests/fixtures/revalidate-fetch/app/posts/[id]/page.js index e46b81b195..5b3c58dadd 100644 --- a/tests/fixtures/revalidate-fetch/app/posts/[id]/page.js +++ b/tests/fixtures/revalidate-fetch/app/posts/[id]/page.js @@ -13,7 +13,8 @@ async function getData(params) { } export default async function Page({ params }) { - const data = await getData(params) + const { id } = await params + const data = await getData({ id }) return ( <> @@ -24,7 +25,7 @@ export default async function Page({ params }) {
Show
{data.name}
Param
-
{params.id}
+
{id}
Time
{Date.now()}
Time from fetch response
diff --git a/tests/fixtures/revalidate-fetch/app/same-fetch-multiple-times/[id]/page.js b/tests/fixtures/revalidate-fetch/app/same-fetch-multiple-times/[id]/page.js index 4f6d48e133..408bba1b11 100644 --- a/tests/fixtures/revalidate-fetch/app/same-fetch-multiple-times/[id]/page.js +++ b/tests/fixtures/revalidate-fetch/app/same-fetch-multiple-times/[id]/page.js @@ -23,7 +23,8 @@ async function getData(params) { } export default async function Page({ params }) { - const data = await getData(params) + const { id } = await params + const data = await getData({ id }) return ( <> @@ -32,7 +33,7 @@ export default async function Page({ params }) {
Show
{data.name}
Param
-
{params.id}
+
{id}
Time
{Date.now()}
Time from fetch response
diff --git a/tests/fixtures/server-components/app/api/static/[slug]/route.ts b/tests/fixtures/server-components/app/api/static/[slug]/route.ts index 44a0667b98..8eb69f8b5a 100644 --- a/tests/fixtures/server-components/app/api/static/[slug]/route.ts +++ b/tests/fixtures/server-components/app/api/static/[slug]/route.ts @@ -4,6 +4,6 @@ export function generateStaticParams() { return [{ slug: 'first' }, { slug: 'second' }] } -export const GET = (_req: NextRequest, { params }) => { - return NextResponse.json({ params }) +export const GET = async (_req: NextRequest, { params }) => { + return NextResponse.json({ params: await params }) } diff --git a/tests/fixtures/server-components/app/product/[slug]/page.js b/tests/fixtures/server-components/app/product/[slug]/page.js index 18c72c22db..12a5cd85d8 100644 --- a/tests/fixtures/server-components/app/product/[slug]/page.js +++ b/tests/fixtures/server-components/app/product/[slug]/page.js @@ -1,12 +1,15 @@ -const Product = ({ params }) => ( -
-

Product {decodeURIComponent(params.slug)}

-

- This page uses generateStaticParams() to prerender a Product - {new Date().toISOString()} -

-
-) +const Product = async ({ params }) => { + const { slug } = await params + return ( +
+

Product {decodeURIComponent(slug)}

+

+ This page uses generateStaticParams() to prerender a Product + {new Date().toISOString()} +

+
+ ) +} export async function generateStaticParams() { return [ @@ -17,4 +20,6 @@ export async function generateStaticParams() { ] } +export const dynamic = 'force-static' + export default Product diff --git a/tests/fixtures/server-components/app/static-fetch/[id]/page.js b/tests/fixtures/server-components/app/static-fetch/[id]/page.js index 24e1abe815..dffec1b1d1 100644 --- a/tests/fixtures/server-components/app/static-fetch/[id]/page.js +++ b/tests/fixtures/server-components/app/static-fetch/[id]/page.js @@ -12,7 +12,8 @@ async function getData(params) { } export default async function Page({ params }) { - const data = await getData(params) + const { id } = await params + const data = await getData({ id }) return ( <> @@ -22,7 +23,7 @@ export default async function Page({ params }) {
Show
{data.name}
Param
-
{params.id}
+
{id}
Time
{new Date().toISOString()}
diff --git a/tests/fixtures/simple/app/api/headers/route.js b/tests/fixtures/simple/app/api/headers/route.js index 5c50b53fdb..426bfd71c8 100644 --- a/tests/fixtures/simple/app/api/headers/route.js +++ b/tests/fixtures/simple/app/api/headers/route.js @@ -1,14 +1,15 @@ import { cookies } from 'next/headers' export const GET = async () => { - cookies().set('foo', 'foo1') - cookies().set('bar', 'bar1') + const localCookies = await cookies() + localCookies.set('foo', 'foo1') + localCookies.set('bar', 'bar1') // Key, value, options - cookies().set('test1', 'value1', { secure: true }) + localCookies.set('test1', 'value1', { secure: true }) // One object - cookies().set({ + localCookies.set({ name: 'test2', value: 'value2', httpOnly: true,