Skip to content

Commit

Permalink
chore: securing updates (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 authored Jan 7, 2025
1 parent 717dfef commit e0ca74b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
19 changes: 0 additions & 19 deletions apps/website/server/api/profile/[id]/streamer/index.post.ts

This file was deleted.

24 changes: 19 additions & 5 deletions apps/website/server/middleware/01.auth.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
export default defineEventHandler(async (event) => {
// Payment webhook dont need auth
if (event.path.startsWith('/api/payment/webhook')) {
return
}

if (event.method === 'OPTIONS') {
event.headers.set('Access-Control-Allow-Origin', '*')
event.headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS')
Expand All @@ -13,5 +8,24 @@ export default defineEventHandler(async (event) => {
const session = await getUserSession(event)
if (session?.user) {
// Already authenticated
return
}

// Payment webhook dont need auth
if (event.path.startsWith('/api/payment/webhook')) {
return
}

// Telegram routes dont need basic auth
if (event.path.startsWith('/api/telegram')) {
return
}

if (event.method !== 'GET') {
// Secured, but without auth
return createError({
statusCode: 401,
statusMessage: 'Unauthorized',
})
}
})

0 comments on commit e0ca74b

Please sign in to comment.