-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation