Admin menu and other non-anonymous elements are sent to AI endpoint

Created on 3 March 2025, about 1 month ago

Problem/Motivation

When sending the rendered HTML to AI endpoint, the subrequest is used, and it has the cookies from current request and also the session. This means that the page is sent to AI endpoint like the current user sees it. If the user has access to toolbar and admin menu, this will also be sent to AI endpoint, but this only increases the number of tokens used, but actually is not relevant for SEO analysis. As search engines access the page as anonymous users maybe subrequest should also be done with anonymous session? Is the purpose of authenticated session to have access to draft of the node?

Steps to reproduce

  1. Login as administrator.
  2. Enable AI logs module.
  3. Send the page for analysis.
  4. Go to AI logs: /admin/config/ai/logging/collection
  5. Observe that in HTML there are menu links from admin menu and other admin UI elements that are not needed for SEO analysis.

Proposed resolution

Cleanup the render array before sending it to AI endpoint. Or use anonymous session if possible.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany a.dmitriiev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024