Skip to content

VSB-TUO/send only the public config in the SSR state - #1731

Merged
milanmajchrak merged 3 commits into
customer/vsb-tuofrom
vsb-tuo/fe-public-config-ssr-state
Nov 17, 2026
Merged

milanmajchrak merged 3 commits into
customer/vsb-tuofrom
vsb-tuo/fe-public-config-ssr-state

Conversation

@milanmajchrak

Copy link
Copy Markdown
Collaborator

References

Description

The SSR state in the HTML of every page carried the whole server config, while config.json already had an allowlist. Both now come from one buildPublicConfig().

Instructions for Reviewers

  • New src/config/public-config.ts holds the allowlist that was inline in config.server.ts. config.server.ts writes it to config.json, server-init.service.ts puts it into the SSR state.
  • The allowlist gets cache.autoSync and universal.transferState. The browser reads them in server-sync-buffer.effects.ts and browser-init.service.ts. Without autoSync a page started from config.json reads timePerMethod of undefined.
  • rest.ssrBaseUrl is dropped. The browser never uses it, and the old ssrBaseUrl: '' / hasSsrBaseUrl scrub goes away with it. Nothing reads hasSsrBaseUrl.
  • ui.baseUrl stays out, as in config.json. In a Docker deployment it is the Node bind address such as http://dspace-angular:4000/, not the public URL, so hasInternalLink() in metadata-values.component.ts returns false for real links with or without it.
  • public-config.spec.ts fails on the old allowlist: ssrBaseUrl is there, autoSync and transferState are missing.
  • How to test: run the SSR build, open the page source of /home. In <script id="dspace-angular-state"> the APP_CONFIG_STATE has ui with only nameSpace and no cache.serverSide, actuators or ui.rateLimiter. /assets/config.json has cache.autoSync.
  • Checked locally with the production SSR build against a 7.6.5 backend: the /home state and config.json hold the same keys (only universal differs), and /home and /search load in headless Chrome without JS errors.
  • Codex review (gpt-6.1-sol, high), 3 rounds: 1 finding fixed (universal.transferState). Its ui.baseUrl finding is declined for the reason above.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR follows all coding best practices based on the Code Conventions Guide
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

🤖 Generated with Claude Code

milanmajchrak and others added 3 commits November 16, 2026 17:13
The SSR transfer state carried the whole server config, while
config.json already had an allowlist. Both now use buildPublicConfig.
The allowlist also gets cache.autoSync, which the browser reads, and
drops rest.ssrBaseUrl, which it does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The browser reads it to decide whether to rehydrate the store from the SSR state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

🟢 Approval recommended

No active review issues remain, and the shared allowlist implementation is covered by tests for retained browser settings and excluded server-only fields.

No open issues 🎉

What changed in this PR

Centralizes the browser-facing configuration allowlist for SSR transfer state and generated config.json files, with tests covering public and excluded settings.

Changes:

  • Added a shared public configuration builder.
  • Updated SSR initialization and config generation to use the allowlist.
  • Added tests for browser-required and server-only configuration fields.
File Description
src/​modules/​app/​server-init.service.ts Uses the shared public configuration builder when storing application configuration in SSR transfer state.
src/​config/​public-config.ts Defines the browser-safe configuration projection and its allowed settings.
src/​config/​public-config.spec.ts Tests that required browser settings are retained and server-only settings are excluded.
src/​config/​config.server.ts Uses the shared public configuration builder when generating assets/config.json.

Review effort: Lite

@milanmajchrak
milanmajchrak merged commit 3b9e351 into customer/vsb-tuo Nov 17, 2026
6 checks passed
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