setup edge caching

This commit is contained in:
spencerwooo
2022-02-10 22:55:59 +08:00
parent de2ccc4e65
commit 2686197b4a
4 changed files with 16 additions and 0 deletions
+4
View File
@@ -131,6 +131,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// If method is GET, then the API is a normal request to the OneDrive API for files or folders
const { path = '/', raw = false, next = '' } = req.query
// Set edge function caching for faster load times, check docs:
// https://vercel.com/docs/concepts/functions/edge-caching
res.setHeader('Cache-Control', 'max-age=60, s-maxage=3600, stale-while-revalidate')
// Sometimes the path parameter is defaulted to '[...path]' which we need to handle
if (path === '[...path]') {
res.status(400).json({ error: 'No path specified.' })