Skip to content

Commit 1ae0f90

Browse files
committed
fix(auth): use Map instead of plain object
1 parent e3dc5a2 commit 1ae0f90

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/runtime/server/utils/auth.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { H3Event } from 'h3'
22
import { getHeader, createError, handleCors } from 'h3'
33
import { $fetch } from 'ofetch'
44

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

77
export async function requireNuxtHubAuthorization(event: H3Event) {
88
// Skip if in development
@@ -39,7 +39,7 @@ export async function requireNuxtHubAuthorization(event: H3Event) {
3939

4040
// Hosted on NuxtHub
4141
if (projectKey) {
42-
if (localCache[secretKeyOrUserToken]) {
42+
if (localCache.has(secretKeyOrUserToken)) {
4343
return
4444
}
4545
// Here the secretKey is a user token
@@ -50,7 +50,7 @@ export async function requireNuxtHubAuthorization(event: H3Event) {
5050
authorization: `Bearer ${secretKeyOrUserToken}`
5151
}
5252
})
53-
localCache[secretKeyOrUserToken] = true
53+
localCache.set(secretKeyOrUserToken, true)
5454
return
5555
}
5656

0 commit comments

Comments
 (0)