Skip to content

Commit 6aa81df

Browse files
committed
feat: update revalidate page with more test scenarios
1 parent a40925f commit 6aa81df

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

demos/default/pages/api/revalidate.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
export default async function handler(req, res) {
2+
const query = req.query
3+
const select = Number(query.select) || 0
4+
5+
const paths = [
6+
'getStaticProps/with-revalidate', // missing leading/trailing slash
7+
'/getStaticProps/with-revalidate', // missing trailing slash
8+
'/getStaticProps/with-revalidate/', // valid path
9+
'/en/getStaticProps/with-revalidate/', // valid path (with locale)
10+
'/fr/getStaticProps/with-revalidate/', // valid path (with locale)
11+
'/', // valid path (index)
12+
'/en', // missing trailing slash (index)
13+
'/fr/', // valid path (index with locale)
14+
'/nothing-here/', // 404
15+
'/getStaticProps/withRevalidate/2/', // valid path (with dynamic route)
16+
'/getStaticProps/withRevalidate/3/', // invalid path (fallback false with dynamic route)
17+
'/getStaticProps/withRevalidate/withFallbackBlocking/3/', // valid path (fallback blocking with dynamic route)
18+
'/blog/nick/', // valid path (with appDir dynamic route)
19+
'/blog/greg/', // invalid path (with appDir dynamic route)
20+
'/blog/rob/hello/', // valid path (with appDir dynamic route)
21+
]
22+
223
try {
3-
const path = '/getStaticProps/with-revalidate/'
4-
await res.revalidate(path)
5-
console.log('Revalidated:', path)
24+
await res.revalidate(paths[select])
625
return res.json({ code: 200, message: 'success' })
726
} catch (err) {
827
return res.status(500).send({ code: 500, message: err.message })

0 commit comments

Comments
 (0)