• Resolved Anees

    (@vaneesv)


    sg_worker worker will throw an error if accept is not present in the request header

    
    if(
            (
                !accept &&
                !( accept.includes('text/html') || accept.includes('*/*') )
            ) ||
          requestURL.pathname.match(/^(?:\/wp-admin\/)/g)
        ) {
          bypassCache = true;
        }
    

    !accept && should be accept &&

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Stanimir Stoyanov

    (@sstoqnov)

    SiteGround Representative

    Hey @vaneesv

    Correct, but the “Accept” header is required in all requests.

    Regards,
    Stanimir

    Thread Starter Anees

    (@vaneesv)

    @sstoqnov Some clients are sending requests without accept.

    Below code is logically incorrect.

    
    // Check if accept has value and the type is not text/html || */* || the user is accessing WP-ADMIN
        // Then only we set bypassCache as true else we will bypass that request and won't modify anything 
        if(
            (
                !accept &&
                !( accept.includes('text/html') || accept.includes('*/*') )
            ) ||
          requestURL.pathname.match(/^(?:\/wp-admin\/)/g)
        ) {
          bypassCache = true;
        }
    

    Please change !accept && to accept && or !accept || on cloudflare-worker.tpl line number 64

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cloudflare worker error (sg_worker)’ is closed to new replies.