Error with Ajax pagelist

I set up routing as required by v9 in my package controller:

public function on_start(){
        \Route::register('/tools/get_list','\Concrete\Package\ForwardLink\Block\NewLinkPartners\Tools\GetList::view');
        \Route::register('/tools/get_old_list','\Concrete\Package\ForwardLink\Block\OldLinkPartners\Tools\GetOldList::view');
    }

Then in view.js I added my ajax function to call my get_list file:

function loadMore(last_index){
  $.ajax({
      //url: CCM_APPLICATION_URL +'/tools/get_list?last_index=' + last_index,
      url: CCM_APPLICATION_URL + '/tools/get_list',
      type: "get",
      beforeSend: function(){
          $('.ajax-load').show();
      }
  }).done(function(data){
      $('.ajax-load').hide();
      $("#new-link-partners").html(data);
      /*if($.trim(data)!=''){
        canLoad=true;;
      }else{
        canLoad=false;;
      }*/
      
  }).fail(function(jqXHR, ajaxOptions, thrownError){
      alert('Server not responding...' + thrownError);
  });
}

However, the ajax call is failing so I see the alert message and I am getting this in the log:

Exception Occurred: /home/appfor/public_html/concrete/src/Http/Middleware/FrameOptionsMiddleware.php:41 Call to a member function has() on null (0)

public function process(Request $request, DelegateInterface $frame)
    {
        $response = $frame->next($request);

        **if ($response->headers->has('X-Frame-Options') === false) {**
            $x_frame_options = $this->config->get('concrete.security.misc.x_frame_options');
            if ($this->stringValidator->notempty($x_frame_options)) {
                $response->headers->set('X-Frame-Options', $x_frame_options);
            }
        }

        return $response;
    }

Seems to be security related, to do with X-Frame options, not sure how to fix it?

Could just be a php8 issue. In which case:

if(!empty($response->headers) && ($response->headers->has(....

Thanks, although I am actually running PHP 7.4 on this project

The above may still get you through the issue. Its just my attributed causality that would be wrong.

Ok thanks, but we’re going down the rabbit hole a bit with this.

I did a similar fix on another 2 files for these errors:

Exception Occurred: /home/appfor/public_html/concrete/src/Http/Middleware/StrictTransportSecurityMiddleware.php:38 Call to a member function has() on null (0)
Exception Occurred: /home/appfor/public_html/concrete/src/Http/Middleware/ContentSecurityPolicyMiddleware.php:38 Call to a member function has() on null (0)

Now getting this one:
Exception Occurred: /home/appfor/public_html/concrete/src/Foundation/Runtime/Run/DefaultRunner.php:132 Call to a member function prepare() on null (0)

Which is the following:

// Create the request to use
$request = $this->createRequest();

if (!$response) {
    if ($this->shouldProcessRequest($request) === false) {
        return null;
    }
    $response = $this->server->handleRequest($request);
}

// Prepare and return the response
**return $response->prepare($request);**
}

Updated to Concrete v9.2.7 but hasn’t changed anything.

It could be your AJAX request is trying to load an entire page through its regular view rather than an ajax action within that controller. Perhaps something to do with the routes.

If that does not turn out to be the case, as this is core code, you should report the original issue on GitHub. As you note, its not just a glitch with the first missing header, getting past that just uncovers further issues.

Some of the marketplace page lists are AJAX enabled (including my Universal Content Puller). I don’t know which can filter at the same time (is that a requirement?). If you don’t have too many pages and too many thumbnails, loading the whole list and in-browser filtering can work well (email me if you would like some details on this).

Thanks John, appreciate your help on this. I am pretty convinced it’s my code at this point so I’ll have a play around with it.

Good to know about your addon I may also end up getting that and seeing how it works.