NextJs 13按需重新验证308 API错误

k10s72fa  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(98)

刚刚启动下一个13应用程序,我试图创建按需重新验证端点,但它一直给我以下错误
Error: Invalid response 308 at DevServer.revalidate

my app dir is 
   /app
     /[locale]
       /(content)
         pages.tsx
   /pages 
     /api
       revalidation.ts

revalidation.ts

import { NextApiRequest, NextApiResponse } from 'next';

export default async function handler(
  resquest: NextApiRequest,
  response: NextApiResponse
) {
  if (resquest.query.secret !== process.env.NEXT_REVALIDATION_TOKEN) {
    return response.status(401).json({ message: 'Invalid token.' });
  }

  const { path } = resquest.query;

  // return response.status(200).json({ revalidated: path });
  await response.revalidate(path as string);

  return response.status(200).json({ revalidated: true });
}

我想我是正确地经过了这条路,但我有一种感觉,这与地点有关?以前有人得过这种病吗?一整晚都被困在上面哈哈

tpgth1q7

tpgth1q71#

我通过将.../api/revalidate更改为.../api/revalidate/修复了308错误。

相关问题