🔧 fix(cloudflare): Corrige l'authentification API Cloudflare avec Global API Key et nouvelle zone ID.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
5
.env
5
.env
@@ -56,8 +56,9 @@ PROD_URL=https://www.e-cosplay.fr
|
||||
VAPID_PK=DsOg7jToRSD-VpNSV1Gt3YAhSwz4l-nqeu7yFvzbSxg
|
||||
VAPID_PC=BKz0kdcsG6kk9KxciPpkfP8kEDAd408inZecij5kBDbQ1ZGZSNwS4KZ8FerC28LFXvgSqpDXtor3ePo0zBCdNqo
|
||||
|
||||
CLOUDFLARE_ZONE_ID=a26d2ecd33d18c984f348eeb060ed5b3
|
||||
CLOUDFLARE_API_TOKEN=cfut_DMt7yjEeManlVJTyTIslUZQQWPVsBwmuktkszp3J635ba612
|
||||
CLOUDFLARE_ZONE_ID=f9e2a44aa512b455c99286d2ae845862
|
||||
CLOUDFLARE_API_EMAIL=contact@e-cosplay.fr
|
||||
CLOUDFLARE_API_KEY=cfk_wXHshV0AmOoKbWE19CIPoWJBeUCtSDUXo2mgkGuNe99eeac8
|
||||
MARCHAND_ID=5685183792
|
||||
###> google/apiclient ###
|
||||
GOOGLE_API_KEY=
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
www.e-cosplay.fr {
|
||||
tls {
|
||||
dns cloudflare cfut_DMt7yjEeManlVJTyTIslUZQQWPVsBwmuktkszp3J635ba612
|
||||
dns cloudflare cfk_wXHshV0AmOoKbWE19CIPoWJBeUCtSDUXo2mgkGuNe99eeac8
|
||||
}
|
||||
root * {{ path }}/public
|
||||
encode zstd gzip
|
||||
@@ -40,7 +40,7 @@ www.e-cosplay.fr {
|
||||
}
|
||||
datas.e-cosplay.fr {
|
||||
tls {
|
||||
dns cloudflare cfut_DMt7yjEeManlVJTyTIslUZQQWPVsBwmuktkszp3J635ba612
|
||||
dns cloudflare cfk_wXHshV0AmOoKbWE19CIPoWJBeUCtSDUXo2mgkGuNe99eeac8
|
||||
}
|
||||
reverse_proxy localhost:27502
|
||||
}
|
||||
|
||||
@@ -21,14 +21,15 @@ class CloudflarePurgeCommand extends Command
|
||||
private const CLOUDFLARE_API_URL = 'https://api.cloudflare.com/client/v4/zones/%s/purge_cache';
|
||||
|
||||
private string $zoneId;
|
||||
private string $apiToken;
|
||||
private string $apiEmail;
|
||||
private string $apiKey;
|
||||
private HttpClientInterface $httpClient;
|
||||
|
||||
public function __construct(HttpClientInterface $httpClient)
|
||||
{
|
||||
// Les variables sont injectées via le conteneur de services (services.yaml)
|
||||
$this->zoneId = $_ENV['CLOUDFLARE_ZONE_ID'];
|
||||
$this->apiToken = $_ENV['CLOUDFLARE_API_TOKEN'];
|
||||
$this->apiEmail = $_ENV['CLOUDFLARE_API_EMAIL'];
|
||||
$this->apiKey = $_ENV['CLOUDFLARE_API_KEY'];
|
||||
$this->httpClient = $httpClient;
|
||||
|
||||
parent::__construct();
|
||||
@@ -38,8 +39,8 @@ class CloudflarePurgeCommand extends Command
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
if (empty($this->zoneId) || empty($this->apiToken)) {
|
||||
$io->error('CLOUDFLARE_ZONE_ID ou CLOUDFLARE_API_TOKEN ne sont pas définis. Veuillez vérifier votre fichier .env.');
|
||||
if (empty($this->zoneId) || empty($this->apiEmail) || empty($this->apiKey)) {
|
||||
$io->error('CLOUDFLARE_ZONE_ID, CLOUDFLARE_API_EMAIL ou CLOUDFLARE_API_KEY ne sont pas définis. Veuillez vérifier votre fichier .env.');
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
@@ -52,8 +53,8 @@ class CloudflarePurgeCommand extends Command
|
||||
sprintf(self::CLOUDFLARE_API_URL, $this->zoneId),
|
||||
[
|
||||
'headers' => [
|
||||
// Utilisation du Token API (méthode recommandée par Cloudflare)
|
||||
'Authorization' => 'Bearer ' . $this->apiToken,
|
||||
'X-Auth-Email' => $this->apiEmail,
|
||||
'X-Auth-Key' => $this->apiKey,
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
// Le payload pour purger tout le cache
|
||||
|
||||
Reference in New Issue
Block a user