Skip to content

Commit b1c1339

Browse files
committed
fix: force-dynamic
1 parent 89f87d0 commit b1c1339

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/app/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ export const generateMetadata = async (): Promise<Metadata> => {
1616
}
1717
}
1818

19+
// ref: https://github.com/opennextjs/opennextjs-cloudflare/issues/652
20+
export const dynamic = "force-dynamic"
21+
1922
const getArticleLikes = async (articles: Article[]) => {
2023
const articleIds = articles.map((article) => article.id)
2124
const query = `select article_id, count(*) from likes where article_id in (${articleIds.map(
2225
() => "?",
2326
)}) group by article_id`
2427

25-
const context = await getCloudflareContext({ async: true })
28+
const context = getCloudflareContext()
2629
const { results } = await context.env.DB.prepare(query)
2730
.bind(...articleIds)
2831
.all<{ article_id: string; "count(*)": string }>()
@@ -38,8 +41,8 @@ const friendLinks = [
3841

3942
export default async function Home() {
4043
const articles = allArticles.toReversed()
41-
const likes = await getArticleLikes(articles)
4244
const recentTweets = await getRecentTweets()
45+
const likes = await getArticleLikes(articles)
4346

4447
const articlesWithLikes = articles.map((article) => {
4548
const like = likes.find((like) => like.article_id === article.id)

0 commit comments

Comments
 (0)