-
Notifications
You must be signed in to change notification settings - Fork 68
fix(server): transform plain text 401/403 to Chrome-compatible HTML for sidekick (#2414) #2613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
42b5478 to
a261c6d
Compare
|
This PR will trigger a patch release when merged. |
…or sidekick (#2414) This completes the fix for issue #2414, addressing the real-world scenario identified by @rofe where the AEM pipeline returns plain text (not HTML) for 401/403 responses. PR #2601 previously added meta tag injection for 401/403 HTML responses, but as noted in the issue comments, the actual pipeline returns plain text. This change transforms those plain text responses into Chrome-compatible HTML that the sidekick can recognize. The generated HTML matches Chrome's structure for plain text responses: - Includes <meta name="color-scheme"> for compatibility - Includes <meta property="hlx:proxyUrl"> for sidekick functionality - Uses <body><pre>401 Unauthorized</pre></body> structure that sidekick detects - Properly escapes URLs containing special characters This allows the AEM sidekick to detect auth errors and enable login functionality. Fixes #2414 Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@rofe the PR will create the right HTML for the 401 to be intercepted, as you can see, Sidekick does decorate the HTML. but: the login does not work, potentially due to something in sidekick itself or admin. I'd be grateful for pointers. |
Here's a pointer: https://github.com/adobe/aem-sidekick/blob/main/src/extension/auth.js#L112 Currenty, the sidekick only injects the |
|
The sidekick has been updated to support localhost URLs with the authorization header injection. See adobe/aem-sidekick#701 |
|
@rofe do we need to wait for Google's approval for the sidekick extension to be released? |
|
@trieloff sidekick v7.20.1 is published |
|
Now I'd need a new example of an auth-protected site. |

Summary
Completes the fix for #2414 by transforming plain text 401/403 responses into Chrome-compatible HTML that the AEM sidekick can recognize and act upon.
Background
Issue #2414 requested injection of the
hlx:proxyUrlmeta tag for 401/403 responses to enable sidekick login functionality.PR #2601 partially addressed this by adding meta tag injection for HTML 401/403 responses. However, @rofe correctly identified that in real-world scenarios, the AEM pipeline returns plain text (not HTML) for these status codes, so the meta tag was never being injected in practice.
Solution
This PR transforms plain text 401/403 responses into Chrome-compatible HTML that:
hlx:proxyUrlmeta tag the sidekick needs<body><pre>401 Unauthorized</pre></body>pattern the sidekick detectsChanges
src/server/utils.js(lines 402-428) to generate Chrome-compatible HTML for plain text 401/403 responses&and"characterstext/plaintotext/htmlTest Plan
Manual Testing Instructions
To test this fix manually with a real auth-enabled site:
Clone and set up the adobe/helix-website repo (has auth enabled):
git clone https://github.com/adobe/helix-website.git cd helix-websiteRun the local dev server using this branch:
Test the 401/403 response transformation:
<pre>401 Unauthorized</pre>(or403 Forbidden)hlx:proxyUrlmeta tag in the<head>color-schememeta tag for Chrome compatibilityInspect the HTML source to confirm structure:
Expected response headers:
Expected HTML body:
Fixes #2414
🤖 Generated with Claude Code