diff --git a/app/api/admin/custom-pages/route.js b/app/api/admin/custom-pages/route.js index e264419..c968300 100644 --- a/app/api/admin/custom-pages/route.js +++ b/app/api/admin/custom-pages/route.js @@ -2,6 +2,10 @@ import pool from '@/lib/db'; import { getUser, requireAdmin } from '@/lib/auth'; +// 避免 GET 被静态优化导致写方法 405(动态接口,不能缓存) +export const dynamic = 'force-dynamic'; + + export async function GET(req) { const user = getUser(req); const forbidden = await requireAdmin(user); diff --git a/app/api/conversations/route.js b/app/api/conversations/route.js index e738893..96def92 100644 --- a/app/api/conversations/route.js +++ b/app/api/conversations/route.js @@ -2,6 +2,10 @@ import pool from '@/lib/db'; import { getUser } from '@/lib/auth'; +// 避免 GET 被静态优化导致写方法 405(动态接口,不能缓存) +export const dynamic = 'force-dynamic'; + + export async function GET(req) { const user = getUser(req); if (!user) { diff --git a/app/api/event-logs/route.js b/app/api/event-logs/route.js index b9176a2..d493b3d 100644 --- a/app/api/event-logs/route.js +++ b/app/api/event-logs/route.js @@ -2,6 +2,10 @@ import pool from '@/lib/db'; import { getUser, requireAdmin } from '@/lib/auth'; +// 避免 GET 被静态优化导致写方法 405(动态接口,不能缓存) +export const dynamic = 'force-dynamic'; + + export async function GET(req) { const user = getUser(req); if (!user) { diff --git a/app/api/links/route.js b/app/api/links/route.js index 70d12de..c6c77dc 100644 --- a/app/api/links/route.js +++ b/app/api/links/route.js @@ -2,6 +2,10 @@ import pool from '@/lib/db'; import { getUser, requireAdmin } from '@/lib/auth'; +// 避免 GET 被静态优化导致写方法 405(动态接口,不能缓存) +export const dynamic = 'force-dynamic'; + + export async function GET() { try { const r = await pool.query('SELECT * FROM friendly_links ORDER BY sort_order'); diff --git a/app/api/posts/route.js b/app/api/posts/route.js index f017e8e..06b4b6d 100644 --- a/app/api/posts/route.js +++ b/app/api/posts/route.js @@ -2,6 +2,10 @@ import pool from '@/lib/db'; import { getUser } from '@/lib/auth'; +// 避免 GET 被静态优化导致写方法 405(动态接口,不能缓存) +export const dynamic = 'force-dynamic'; + + export async function GET(req) { const url = new URL(req.url); const sort = url.searchParams.get('sort') === 'hot' ? 'updated_at' : 'created_at'; diff --git a/app/api/reports/route.js b/app/api/reports/route.js index 3828598..b938e65 100644 --- a/app/api/reports/route.js +++ b/app/api/reports/route.js @@ -2,6 +2,10 @@ import pool from '@/lib/db'; import { getUser, requireAdmin } from '@/lib/auth'; +// 避免 GET 被静态优化导致写方法 405(动态接口,不能缓存) +export const dynamic = 'force-dynamic'; + + export async function GET(req) { const user = getUser(req); const forbidden = await requireAdmin(user); diff --git a/app/api/settings/route.js b/app/api/settings/route.js index e736c09..2bb57ae 100644 --- a/app/api/settings/route.js +++ b/app/api/settings/route.js @@ -2,6 +2,9 @@ import pool from '@/lib/db'; import { getUser, requireAdmin } from '@/lib/auth'; +// 避免 GET 被静态优化导致 PUT 405(动态接口,不能缓存) +export const dynamic = 'force-dynamic'; + export async function GET() { try { const r = await pool.query('SELECT key, value FROM settings');