Skip to content

TUL/Fix dspace-customers 1083 R22: SSR static pages no longer trust the Host header; SSR cache keyed by origin and language - #1754

Open
jr-rk wants to merge 1 commit into
customer/TULfrom
tul/fe-ssr-host-header-cache-key
Open

jr-rk wants to merge 1 commit into
customer/TULfrom
tul/fe-ssr-host-header-cache-key

Conversation

@jr-rk

@jr-rk jr-rk commented Nov 26, 2026 •

Copy link
Copy Markdown

References

Port of dtq-dev PR 1669 (commit 60f6ccb). dspace-customers issue 1083, finding R22.
In comparison with the source, the diff is 1:1.

Description

During SSR, static HTML pages were loaded from the request Host and cached in the bot cache under the path only. Now they are loaded from the ui.baseUrl origin, the SSR caches are keyed by origin, path and language, the bot cache serves only anonymous requests, and a static page name like ..%2Findex is refused.

Instructions for Reviewers

  • html-content.service.ts and its spec: the same as the source (TUL had the same file as dtq-dev before the fix).
  • server.ts and new ssr-cache-key.util.ts: the same as the source. Only the import block and the /reload line conflicted; TUL keeps its own "cache only 200 responses" check.
  • Tests: ssr-cache-key.util.spec.ts and html-content.service.spec.ts (9 specs pass locally on Node 18). ESLint is clean on the changed files, yarn run build:prod passes. Not tested on a running SSR server.

Checklist

  • My PR is created against the branch it ports to
  • My PR is small in size
  • My PR follows the code conventions and passes ESLint
  • My PR passes the relevant specs and includes new or updated specs
  • My PR includes details on how to test it
  • No new dependencies, no new configuration

…he Host header; SSR cache keyed by origin and language

Port of dtq-dev PR 1669 (commit 60f6ccb). html-content.service.ts and
its spec apply unchanged (same file as on dtq-dev before the fix). In
server.ts only the import block and the /reload line conflicted; TUL keeps
its own "cache only 200 responses" check.
@jr-rk jr-rk self-assigned this Nov 26, 2026
@jr-rk
jr-rk requested a lite review from Copilot November 26, 2026 10:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

End-to-end validation on a running SSR deployment behind the configured proxy is still needed to verify the security-sensitive origin selection, static-path handling, and anonymous/bot cache isolation changes.

No open issues 🎉

What changed in this PR

Hardens SSR static-page loading and caching by removing reliance on the request Host header, partitioning cached pages by origin and language, restricting bot-cache reads to anonymous requests, and rejecting encoded path traversal attempts.

Changes:

  • Loads SSR static HTML from the configured UI origin.
  • Adds origin-, language-, and URL-aware SSR cache keys.
  • Restricts bot-cache use to anonymous requests.
  • Validates static page names after URL decoding and adds focused tests.
File Description
src/​app/​shared/​ssr-cache-key.util.ts Defines SSR cache keys incorporating the request origin, language cookie, and URL.
src/​app/​shared/​ssr-cache-key.util.spec.ts Tests cache separation by language and request origin.
src/​app/​shared/​html-content.service.ts Loads SSR content from the configured UI origin and rejects unsafe decoded filenames.
src/​app/​shared/​html-content.service.spec.ts Tests configured-origin loading and path traversal rejection.
server.ts Applies the new cache keys and prevents authenticated requests from reading the bot cache.

Review effort: Lite

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants