From 18691d930ebdac57b270d7202b5e8c24aee4002e Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Sat, 7 Mar 2026 22:37:36 +0100 Subject: [PATCH] Utiliser le chemin /organisations/{orgaId}/ pour l'API Clever Cloud --- .env.example | 2 ++ README.md | 1 + src/pages/api/rebuild.ts | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index dfa7f14..63bd40b 100644 --- a/.env.example +++ b/.env.example @@ -10,5 +10,7 @@ PUBLIC_STORYBLOK_TOKEN= # STORYBLOK_WEBHOOK_SECRET= # Token OAuth Clever Cloud (généré via clever login puis ~/.config/clever-cloud/clever-tools.json) # CLEVER_TOKEN= +# ID de l'organisation Clever Cloud (orga_xxxxxxxx) +# CLEVER_ORGA_ID= # ID de l'application Clever Cloud de production (app_xxxxxxxx) # CLEVER_APP_ID_PRODUCTION= diff --git a/README.md b/README.md index 758bf94..6c52161 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Le serveur démarre sur le port `8080` par défaut (configurable via `PORT`). | `PUBLIC_STORYBLOK_IS_PREVIEW` | *(non défini)* | `true` | | `STORYBLOK_WEBHOOK_SECRET` | - | Secret du webhook StoryBlok | | `CLEVER_TOKEN` | - | Token OAuth Clever Cloud | +| `CLEVER_ORGA_ID` | - | ID de l'organisation (orga_xxx) | | `CLEVER_APP_ID_PRODUCTION` | - | ID de l'app production (app_xxx) | | `CC_POST_BUILD_HOOK` | `npm run build` | `npm run build` | | `HOST` | - | `0.0.0.0` | diff --git a/src/pages/api/rebuild.ts b/src/pages/api/rebuild.ts index 6cde799..57c7891 100644 --- a/src/pages/api/rebuild.ts +++ b/src/pages/api/rebuild.ts @@ -4,9 +4,10 @@ import { createHmac, timingSafeEqual } from 'node:crypto'; export const POST: APIRoute = async ({ request }) => { const webhookSecret = import.meta.env.STORYBLOK_WEBHOOK_SECRET; const token = import.meta.env.CLEVER_TOKEN; + const orgaId = import.meta.env.CLEVER_ORGA_ID; const appId = import.meta.env.CLEVER_APP_ID_PRODUCTION; - if (!webhookSecret || !token || !appId) { + if (!webhookSecret || !token || !orgaId || !appId) { return new Response('Missing server configuration', { status: 500 }); } @@ -19,7 +20,7 @@ export const POST: APIRoute = async ({ request }) => { } const response = await fetch( - `https://api-bridge.clever-cloud.com/v2/self/applications/${appId}/instances`, + `https://api-bridge.clever-cloud.com/v2/organisations/${orgaId}/applications/${appId}/instances`, { method: 'POST', headers: { Authorization: `Bearer ${token}` },