Skip to content

Bug: Standalone Debugbar is not properly initialized #9949

@michalsn

Description

@michalsn

PHP Version

8.5

CodeIgniter4 Version

4.7

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

macOS

Which server did you use?

cli-server (PHP built-in webserver)

Environment

development

Database

MySQL 8

What happened?

When processing non-HTML requests, the Debugbar attaches special headers such as Debugbar-Link, which provide a URL to render the Debugbar in a separate request.

Although the Debugbar interface is rendered when visiting that URL, it is not fully initialized, which prevents any interaction with it.

Steps to Reproduce

  1. Add the following route:
// app/Config/Routes.php
$routes->get('ajax', 'Home::ajax');
  1. Add this method to Home controller:
// app/Controllers/Home.php
public function ajax()
{
    $this->response->setJSON([]);
}
  1. Add the following script to welcome_message.php:
<script>
    fetch('/ajax', {
        headers: {
            'Accept': 'application/json',
            'X-Requested-With': 'XMLHttpRequest'
        }
    })
</script>
  1. Open Developer Tools and inspect the Network tab.
  2. Open the main page in the browser.
  3. Check the response headers of the /ajax request and look for the Debugbar-Link header.
  4. Copy the URL from Debugbar-Link and open it in a new tab.

The Debugbar is displayed, but it is not interactive because it is not properly initialized.

Expected Output

The Debugbar should be fully interactive, just as it is when rendered within a standard HTML response.

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugVerified issues on the current code behavior or pull requests that will fix them

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions