@@ -31,25 +31,27 @@ const buildConfig = require(process.env.BUILD_CONFIG && existsSync(process.env.B
3131if ( buildConfig . cloudflare && buildConfig . cloudflare . enabled && buildConfig . cloudflare . authKey ) {
3232 ( async ( ) => {
3333 try {
34- const client = axios . create ( { baseURL : 'https://api.cloudflare.com/client/v4' } ) ;
35-
36- // purge cache
37- await client . post ( '/zones/' + buildConfig . cloudflare . zoneId + '/purge_cache' , {
38- hosts : [ websiteConfig . webUri . hostname ]
39- } , {
34+ const client = axios . create ( {
35+ baseURL : 'https://api.cloudflare.com/client/v4' ,
4036 headers : {
4137 'X-Auth-Key' : buildConfig . cloudflare . authKey ,
4238 'X-Auth-Email' : buildConfig . cloudflare . authEmail ,
4339 'Content-Type' : 'application/json'
4440 }
4541 } ) ;
42+
43+ // purge cache
44+ await client . post ( '/zones/' + buildConfig . cloudflare . zoneId + '/purge_cache' , { purge_everything : true } ) ;
45+
4646 // eslint-disable-next-line no-console
47- console . log ( 'Purge Cloudflare cache for %s.' , websiteConfig . webUri . hostname ) ;
47+ console . log ( 'Purged Cloudflare cache for %s.' , websiteConfig . webUri . hostname ) ;
4848 process . exit ( 0 ) ;
4949
5050 } catch ( err ) {
5151 // eslint-disable-next-line no-console
52- console . error ( 'Cloudflare error: %s' , JSON . stringify ( err ) ) ;
52+ console . error ( 'Cloudflare error: %s' , err ) ;
53+ // eslint-disable-next-line no-console
54+ console . error ( err && err . response && err . response . data ? JSON . stringify ( err . response . data , null , ' ' ) : err ) ;
5355 process . exit ( 1 ) ;
5456 }
5557 } ) ( ) ;
0 commit comments