mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
setup edge caching
This commit is contained in:
@@ -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.' })
|
||||
|
||||
Reference in New Issue
Block a user