Commit 27174a8 1 parent 5296688 commit 27174a8 Copy full SHA for 27174a8
File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import type { H3Event } from 'h3'
2
2
import { getHeader , createError , handleCors } from 'h3'
3
3
import { $fetch } from 'ofetch'
4
4
5
+ let localCache : Record < string , boolean > = { }
6
+
5
7
export async function requireNuxtHubAuthorization ( event : H3Event ) {
6
8
// Skip if in development
7
9
if ( import . meta. dev ) {
@@ -37,6 +39,9 @@ export async function requireNuxtHubAuthorization(event: H3Event) {
37
39
38
40
// Hosted on NuxtHub
39
41
if ( projectKey ) {
42
+ if ( localCache [ secretKeyOrUserToken ] ) {
43
+ return
44
+ }
40
45
// Here the secretKey is a user token
41
46
await $fetch ( `/api/projects/${ projectKey } ` , {
42
47
baseURL : process . env . NUXT_HUB_URL || 'https://admin.hub.nuxt.com' ,
@@ -45,6 +50,7 @@ export async function requireNuxtHubAuthorization(event: H3Event) {
45
50
authorization : `Bearer ${ secretKeyOrUserToken } `
46
51
}
47
52
} )
53
+ localCache [ secretKeyOrUserToken ] = true
48
54
return
49
55
}
50
56
You can’t perform that action at this time.
0 commit comments