|
1 | 1 | 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 | + |
2 | 23 | try {
|
3 |
| - const path = '/getStaticProps/with-revalidate/' |
4 |
| - await res.revalidate(path) |
5 |
| - console.log('Revalidated:', path) |
| 24 | + await res.revalidate(paths[select]) |
6 | 25 | return res.json({ code: 200, message: 'success' })
|
7 | 26 | } catch (err) {
|
8 | 27 | return res.status(500).send({ code: 500, message: err.message })
|
|
0 commit comments