@@ -8,9 +8,12 @@ async function handleWhitelabelRequest(request) {
88 let slug = request . path . substring ( 4 )
99
1010 let templateContentType = 'text/html;charset=UTF-8'
11- let templateDomain ;
11+ let templateDomain
1212
13- let devPublicKeys = [ "dba793b5eb837611498d0b809aefdefcb6f113310b272f6114435964670125a1" , "04a39378b6abc3e3ee870828471636a9d1e157b1a7720821aed4c260108ebe43" ]
13+ let devPublicKeys = [
14+ 'dba793b5eb837611498d0b809aefdefcb6f113310b272f6114435964670125a1' ,
15+ '04a39378b6abc3e3ee870828471636a9d1e157b1a7720821aed4c260108ebe43' ,
16+ ]
1417
1518 if ( devPublicKeys . includes ( API_KEY ) ) {
1619 templateDomain = 'wait-dev.crowdhandler.com'
@@ -142,9 +145,22 @@ async function handleRequest(event) {
142145 const validToken = / ( .* \d + .* ) /
143146 let language
144147 let waitingRoomDomain
148+
149+ let statusIdentifier = / ^ \/ c h \/ s t a t u s $ /
145150 let whiteLabelIdentifier = / ^ \/ c h \/ .* /
146151
147- console . log ( urlAttributes )
152+ //Check if the request is for a status check and handle response
153+ if ( statusIdentifier . test ( path ) === true ) {
154+ return new Response (
155+ JSON . stringify ( { integration : 'cloudflare' , status : 'ok' } ) ,
156+ {
157+ headers : {
158+ 'content-type' : 'text/plain' ,
159+ 'cache-control' : 'public, max-age=60' ,
160+ } ,
161+ } ,
162+ )
163+ }
148164
149165 //Check if the request is for a whitelabel waiting room and handle response
150166 if ( whiteLabelIdentifier . test ( path ) === true ) {
@@ -292,13 +308,16 @@ async function handleRequest(event) {
292308 }
293309
294310 //Handle Wordpress exclusions
295- let origin_type ;
311+ let origin_type
296312 if ( typeof ORIGIN_TYPE !== 'undefined' ) {
297- origin_type = ORIGIN_TYPE ;
313+ origin_type = ORIGIN_TYPE
298314 }
299315
300316 if ( origin_type === 'wordpress' ) {
301- if ( wordpressExclusions . test ( path ) === true || wordpressExclusions . test ( queryString ) === true ) {
317+ if (
318+ wordpressExclusions . test ( path ) === true ||
319+ wordpressExclusions . test ( queryString ) === true
320+ ) {
302321 console . log ( 'Wordpress exclusion detected. Going straight to origin.' )
303322 //Return the origin page
304323 return await fetch ( modifiedRequest )
0 commit comments