Skip to content

fix(server): auth to da.live preview host for content.da.live images#2754

Merged
kptdobe merged 4 commits into
mainfrom
rewrite-da-content-image-urls
Jul 8, 2026
Merged

fix(server): auth to da.live preview host for content.da.live images#2754
kptdobe merged 4 commits into
mainfrom
rewrite-da-content-image-urls

Conversation

@kptdobe

@kptdobe kptdobe commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • content.da.live image URLs in local content/ pages are rewritten to the site's *.preview.da.live host, since content.da.live is auth-gated and not reachable during local dev.
  • Since that preview host also requires an IMS-authenticated cookie, a client-side bootstrap is injected (only on pages that reference it): it first checks for an existing valid cookie by probing an actual asset (not the site root, which is often served regardless of auth), and only if that fails loads IMS / redirects through a new /.aem/cli/da-login dev-server route (the darkalley IMS client only allows its fixed :9898 callback as redirect_uri, so a plain client-side signIn() redirects to the wrong place).
  • After the cookie is set, the page reloads once so already-broken image requests are retried with the cookie attached.

Fixes #2752

Test plan

  • npm run lint
  • test/server-utils.test.js — URL rewrite, auth-script injection, probe-path extraction
  • test/server.test.jscontent/ serving and da.live login redirect suites (redirect validation incl. open-redirect rejection)
  • test/content/da-auth.test.jsstartDaLoginRedirect
  • Manually verified end-to-end against a real aem content clone + aem up project (images broken → auth redirect → images load; reload not required after cookie is set)

🤖 Generated with Claude Code

kptdobe and others added 2 commits July 3, 2026 09:00
content.da.live is not publicly reachable for rendering images during
local dev, so img src referencing the org/site content store must be
rewritten to the aem preview domain.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
content.da.live is auth-gated for images, so local content/ pages need
an IMS-authenticated cookie on the site's *.preview.da.live host to
render them. Adds a client-side bootstrap that checks for an existing
valid cookie/session first, and only then falls back to IMS login
(via a dev-server-driven redirect, since the darkalley IMS client only
allows its fixed :9898 callback as redirect_uri).

Fixes #2752

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comment thread src/server/HelixServer.js Fixed
Comment thread src/server/HelixServer.js Fixed
CodeQL (js/missing-rate-limiting) flagged /.aem/cli/da-login and
/__internal__/da-content-auth.js: both trigger real side effects (an
IMS redirect, a live callback server bind on :9898), so cap abuse from
a runaway page/script with express-rate-limit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@kptdobe kptdobe requested review from andreituicu and tripodsan July 3, 2026 08:22
@tripodsan

Copy link
Copy Markdown
Contributor

I cannot judge if this is correct. looks way too complicated.... why are the image references on content.da.live ?

@kptdobe

kptdobe commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

I cannot judge if this is correct. looks way too complicated.... why are the image references on content.da.live ?

This is how DA works today: when you d&d an image inside a "page" document, image is uploaded inside a ".page" folder next to "page" and is referenced via content.da.lve.

And yes, it is really complicated.

tripodsan
tripodsan previously approved these changes Jul 8, 2026
…age-urls

# Conflicts:
#	src/server/HelixServer.js
@kptdobe kptdobe merged commit c3e4b53 into main Jul 8, 2026
6 of 7 checks passed
@kptdobe kptdobe deleted the rewrite-da-content-image-urls branch July 8, 2026 13:20
@tripodsan

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 16.20.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[content] Missing images after clone and on aem up

3 participants