From e5a2e639944ea1465a2f03c2f45d837f8dc74681 Mon Sep 17 00:00:00 2001 From: alma Date: Sun, 4 May 2025 13:51:14 +0200 Subject: [PATCH] pages s3 --- .env | 6 ++++++ app/api/nextcloud/status/route.ts | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.env b/.env index 462eba20..2771b2cc 100644 --- a/.env +++ b/.env @@ -12,6 +12,12 @@ KEYCLOAK_ADMIN_PASSWORD=PW5jfqX00m DOLIBARR_API_URL=https://mediations.slm-lab.net/api/index.php/ DOLIBARR_API_KEY=2znq976PzZz1q2JSe9DG2A3hmbNMGIh8 +# MinIO S3 configuration +MINIO_S3_UPLOAD_BUCKET_URL="https://dome-api.slm-lab.net/" +MINIO_AWS_REGION="eu-east-1" +MINIO_AWS_S3_UPLOAD_BUCKET_NAME="pages" + + NEXTCLOUD_URL=https://espace.slm-lab.net NEXTCLOUD_CLIENT_ID=espace.slm-lab.net NEXTCLOUD_CLIENT_SECRET=YHLVMGpu0nGRaP7gMDpSjRr1ia6HiSr1 diff --git a/app/api/nextcloud/status/route.ts b/app/api/nextcloud/status/route.ts index eadfebb3..5d93b730 100644 --- a/app/api/nextcloud/status/route.ts +++ b/app/api/nextcloud/status/route.ts @@ -5,7 +5,7 @@ import { authOptions } from '@/app/api/auth/[...nextauth]/route'; // This file serves as an adapter to redirect requests from the old NextCloud // status endpoint to the new MinIO S3 status endpoint -export async function GET() { +export async function GET(request: Request) { try { // Get session const session = await getServerSession(authOptions); @@ -13,10 +13,14 @@ export async function GET() { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } + // Get the base URL from the request + const { protocol, host } = new URL(request.url); + const baseUrl = `${protocol}//${host}`; + // Forward the request to the new endpoint - const response = await fetch('/api/storage/status', { + const response = await fetch(`${baseUrl}/api/storage/status`, { headers: { - 'Cookie': session ? 'next-auth.session-token=' + (session as any).accessToken : '' + 'Cookie': request.headers.get('cookie') || '' } });