Skip to content

Commit

Permalink
fix(auth): use Map instead of plain object
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed May 15, 2024
1 parent e3dc5a2 commit 1ae0f90
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/runtime/server/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { H3Event } from 'h3'
import { getHeader, createError, handleCors } from 'h3'
import { $fetch } from 'ofetch'

const localCache: Record<string, boolean> = {}
const localCache: Map<string, boolean> = new Map()

export async function requireNuxtHubAuthorization(event: H3Event) {
// Skip if in development
Expand Down Expand Up @@ -39,7 +39,7 @@ export async function requireNuxtHubAuthorization(event: H3Event) {

// Hosted on NuxtHub
if (projectKey) {
if (localCache[secretKeyOrUserToken]) {
if (localCache.has(secretKeyOrUserToken)) {
return
}
// Here the secretKey is a user token
Expand All @@ -50,7 +50,7 @@ export async function requireNuxtHubAuthorization(event: H3Event) {
authorization: `Bearer ${secretKeyOrUserToken}`
}
})
localCache[secretKeyOrUserToken] = true
localCache.set(secretKeyOrUserToken, true)
return
}

Expand Down

0 comments on commit 1ae0f90

Please sign in to comment.