(request: FastifyRequest, reply: FastifyReply)
| 35 | } |
| 36 | |
| 37 | export async function authHook(request: FastifyRequest, reply: FastifyReply): Promise<void> { |
| 38 | if (!cachedToken) return |
| 39 | |
| 40 | const url = request.url |
| 41 | |
| 42 | if (url.startsWith('/api/')) { |
| 43 | return requireBearerToken(request, reply) |
| 44 | } |
| 45 | |
| 46 | if (url.startsWith('/_web/')) { |
| 47 | if (requireAuthEnabled) return requireBearerToken(request, reply) |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | // Static files and SPA fallback are public |
| 52 | } |
| 53 | |
| 54 | function requireBearerToken(request: FastifyRequest, reply: FastifyReply): void { |
| 55 | if (!cachedToken) return |
no test coverage detected