Skip to content

Commit

Permalink
Add logic to require the API token to be verfied in order to invalida…
Browse files Browse the repository at this point in the history
…te caches
  • Loading branch information
Dobefu committed May 5, 2024
1 parent f68bb74 commit 41a7f9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions frontend/base/server/api/cache/invalidate.post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import process from 'node:process'

export default defineEventHandler(async (event) => {
const { tags } = await readBody(event)
const { headers } = event
const token = headers.get('token') ?? ''

if (token !== process.env.BACKEND_API_KEY)
return new Response('Unauthorized', { status: 401 })

const storage = useStorage('cacheData')
const storageKeys = await storage.getKeys()
Expand Down

0 comments on commit 41a7f9a

Please sign in to comment.