Repository navigation
Conversation
…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.
There was a problem hiding this comment.
🔵 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.baseUrlorigin, the SSR caches are keyed by origin, path and language, the bot cache serves only anonymous requests, and a static page name like..%2Findexis refused.Instructions for Reviewers
html-content.service.tsand its spec: the same as the source (TUL had the same file as dtq-dev before the fix).server.tsand newssr-cache-key.util.ts: the same as the source. Only the import block and the/reloadline conflicted; TUL keeps its own "cache only 200 responses" check.ssr-cache-key.util.spec.tsandhtml-content.service.spec.ts(9 specs pass locally on Node 18). ESLint is clean on the changed files,yarn run build:prodpasses. Not tested on a running SSR server.Checklist