Hey @dulnan, great project here 🙌
I'm running into an issue where I'm calling the purge API from another server. For that, I had to configure CORS for my purge route.
This is what I added:
// ~/server/middleware/cors.ts
export default defineEventHandler((event) => {
if (!event.req.url?.startsWith('/__cache/')) return
setResponseHeaders(event, {
'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Headers': '*',
'Access-Control-Expose-Headers': '*',
})
if (event.method === 'OPTIONS') {
event.node.res.statusCode = 204
event.node.res.statusMessage = 'No Content.'
return 'OK'
}
})
I can add it to docs if you agree. It might be useful to other people.
Hey @dulnan, great project here 🙌
I'm running into an issue where I'm calling the purge API from another server. For that, I had to configure CORS for my purge route.
This is what I added:
I can add it to docs if you agree. It might be useful to other people.