Skip to content

Commit

Permalink
fix: throw only if no projectKey defined
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Feb 26, 2024
1 parent 98903c0 commit ef9f0eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/runtime/server/middleware/1.hub-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ export default eventHandler(async (event) => {
message: 'Missing Authorization header'
})
}
const projectKey = process.env.NUXT_HUB_PROJECT_KEY

// Self-hosted NuxtHub project, user has to set a secret key to access the proxy
const projectSecretKey = process.env.NUXT_HUB_PROJECT_SECRET_KEY
if (projectSecretKey && secretKeyOrUserToken === projectSecretKey) {
return
} else if (projectSecretKey) {
} else if (projectSecretKey && !projectKey) {
throw createError({
statusCode: 401,
message: 'Invalid secret key'
})
}

// Hosted on NuxtHub
const projectKey = process.env.NUXT_HUB_PROJECT_KEY
if (projectKey) {
// Here the secretKey is a user token
await $fetch(`/api/projects/${projectKey}`, {
Expand Down

0 comments on commit ef9f0eb

Please sign in to comment.