Skip to content

Commit

Permalink
feat(auth-key): do not fetch raw
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed May 12, 2023
1 parent 8968f1b commit c4be6b9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions nuxt/server/api/auth-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ export const useJwtPublicKey = async () => {
const jwtPublicKeyPath = process.env.POSTGRAPHILE_JWT_PUBLIC_KEY_FILE

if (config.public.stagingHost) {
const httpResp = await ofetch.raw(
return await ofetch<string>(
`https://${config.public.stagingHost}/api/auth-key`
)

if (!httpResp.ok) return undefined

return httpResp._data
} else {
if (!jwtPublicKeyPath || !fs.existsSync(jwtPublicKeyPath)) return undefined

return fs.readFileSync(jwtPublicKeyPath, 'utf-8')
return jwtPublicKeyPath && fs.existsSync(jwtPublicKeyPath)
? fs.readFileSync(jwtPublicKeyPath, 'utf-8')
: undefined
}
}

0 comments on commit c4be6b9

Please sign in to comment.