Skip to content

Commit bb0635d

Browse files
committed
Example: ensure middleware pages don't cache
1 parent 774eb85 commit bb0635d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

example/pages/middleware-geolocation.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { useRouter } from "next/router";
22
import Layout from "../components/layout";
33

4-
export default function Page() {
4+
export async function getServerSideProps(context) {
5+
return {
6+
props: {
7+
qs: JSON.stringify(context.query),
8+
},
9+
};
10+
}
11+
12+
export default function Page({ qs }) {
513
return (
614
<Layout>
715
<article>
@@ -11,7 +19,7 @@ export default function Page() {
1119
<hr />
1220
<p>
1321
<b>Test 1:</b>
14-
URL query contains country, city, and region: {JSON.stringify(useRouter().query)}
22+
URL query contains country, city, and region: {qs}
1523
</p>
1624
</article>
1725
</Layout>

0 commit comments

Comments
 (0)