Skip to content

Commit d97b03a

Browse files
committed
chore: prepare hub server api authorization
1 parent 1da7e19 commit d97b03a

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

_nuxthub/server/api/_hub/blob/[...pathname].delete.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export default eventHandler(async (event) => {
2-
// TODO: handle authorization
32
const { pathname } = await getValidatedRouterParams(event, z.object({
43
pathname: z.string().min(1)
54
}).parse)

_nuxthub/server/api/_hub/blob/[...pathname].get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default eventHandler(async (event) => {
2-
// TODO: handle authorization
2+
// TODO: handle caching in production
33
const { pathname } = await getValidatedRouterParams(event, z.object({
44
pathname: z.string().min(1)
55
}).parse)

_nuxthub/server/api/_hub/blob/[...pathname].head.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
export default eventHandler(async (event) => {
2-
// TODO: handle authorization
3-
42
const { pathname } = await getValidatedRouterParams(event, z.object({
53
pathname: z.string().min(1)
64
}).parse)
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
export default eventHandler(async (event) => {
2-
// TODO: handle authorization
3-
42
return useBlob().list()
53
})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default eventHandler(async (event) => {
2+
if (/^\/api\/_hub\//.test(event.path) === false || import.meta.dev) {
3+
return
4+
}
5+
6+
// Authorize the request
7+
// console.log('Authorizing the request to hub.nuxt.com...')
8+
// Format Authorization: Bearer <secretKey>
9+
// const [, secretKey] = (getHeader(event, 'authorization') || '').split(' ')
10+
// await $fetch('https://hub.nuxt.com/api/authorize', {
11+
// method: 'HEAD',
12+
// headers: {
13+
// 'x-project-id': process.env.NUXT_HUB_PROJECT_ID || '',
14+
// authorization: `Bearer ${secretKey}`
15+
// }
16+
// })
17+
})

0 commit comments

Comments
 (0)