Improve HTTP Basic Auth docs. Improves #269

This commit is contained in:
Enrico Ros
2023-12-10 00:17:34 -08:00
parent 5808c5ae27
commit 8023d4fd7e
2 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ to secure your application. To enable it in `big-AGI`, you **must manually build
- Build `big-AGI` with HTTP authentication enabled:
- Clone the repository
- Rename `middleware_BASIC_AUTH.ts` to `middleware_BASIC_AUTH.ts`
- Rename `middleware_BASIC_AUTH.ts` to `middleware.ts`
- Build: follow the build instructions in [Deploy manually](../README.md#-deploy-manually) or [Deploying with Docker](deploy-docker.md)
- Configure the following [environment variables](environment-variables.md) before launching `big-AGI`:
+9 -5
View File
@@ -1,14 +1,18 @@
/**
* Middleware to protect `big-AGI` with HTTP Basic Authentication
*
* For more information on how to deploy with HTTP Basic Authentication, see:
* - [deploy-authentication.md](docs/deploy-authentication.md)
*/
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
// noinspection JSUnusedGlobalSymbols
/**
* Middleware to protect with HTTP Basic Authentication.
*/
export function middleware(request: NextRequest) {
// Validate http basic auth configuration
// Validate deployment configuration
if (!process.env.HTTP_BASIC_AUTH_USERNAME || !process.env.HTTP_BASIC_AUTH_PASSWORD) {
console.warn('HTTP Basic Authentication is enabled but not configured');
return new Response('Unauthorized/Unconfigured', unauthResponse);
@@ -48,7 +52,7 @@ export const config = {
'/',
// Include pages
'/(call|index|news|personas|link)(.*)',
// Include API routes (the most important part to block)
// Include API routes
'/api(.*)',
// Note: this excludes _next, /images etc..
],