API REST Authentication not working

I’m trying Kirby CMS for the first time, and i would like to experiment the headless part of the CMS.
i’m struggling with the authentication for API REST from js and Insomnia.
I’m running Kirby with ddev and i already changed my site/config/config.php file in this way:


return [
    'debug' => true,
    'api' => [
        'basicAuth' => true,
        'allowInsecure' => true
    ]
];

I followed every step of the tutorial in this page, and tried with more than account and password, but nothing. When i try to run the following fetch srcipt:

 url = 'http://my-domain/api/query'; 
 username = 'username'; 
 password = 'password'; 
 headers = new Headers(); 
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password)); 

headers.append('Content-Type', 'application/json'); 

fetch(url, { method: 'POST', headers: headers}) .then(response => response.json()) 
.then(data => console.log(data)) 
.catch(error => console.error('Error:', error));

I got the same error even with Insomnia.
I’m using Ubuntu 22.04.5 LTS and Kirby version 4.

I also tried to change username with the user email, tried with localhost, 127.0.0.1, custom domani provided but ddev in https, but it didn’t work.

What i’m missing?
There’s something i should do on panel?

Thank you in advance

Did you install the KQL plugin? Otherwise, the endpoint would not be valid. Username is the email address.

It was that!
I missed that part of the documentation.
Thank you so much for the help, now is solved.