Skip to content

Add src/static-files to build assets#103

Merged
kosarko merged 2 commits intoclarin-v7from
98-render-the-static-pages-in-ssr-mode
Mar 10, 2026
Merged

Add src/static-files to build assets#103
kosarko merged 2 commits intoclarin-v7from
98-render-the-static-pages-in-ssr-mode

Conversation

@amadulhaxxani
Copy link

Update angular.json to include "src/static-files" in the build assets array so files placed there are copied into the build output. This ensures additional static resources are available at runtime without changing code paths.

Problem description

Static HTML files located in src/static-files/ were not included in the production SSR build output.
During server-side rendering, StaticPageComponent fetches these files via HttpClient. In production, the request resolves against dist/browser/, but since the files were not copied there, SSR returned 404 responses and static pages were not rendered correctly when accessed via tools like curl.

Analysis

The issue was caused by missing asset configuration in angular.json.
Adding "src/static-files" to the assets array ensures the files are copied into dist/browser/static-files/ during build, making them accessible at runtime for SSR without requiring changes to component or service logic.

Problems

No unexpected issues occurred. Build and SSR rendering were verified locally. Static pages now return HTTP 200 and correct content when accessed via curl.

Copilot review

  • ✅ Requested review from Copilot

Update angular.json to include "src/static-files" in the build assets array so files placed there are copied into the build output. This ensures additional static resources are available at runtime without changing code paths.
Copilot AI review requested due to automatic review settings February 16, 2026 14:17
@amadulhaxxani amadulhaxxani linked an issue Feb 16, 2026 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes an SSR issue where static HTML files in the src/static-files/ directory were not being copied to the production build output, causing 404 errors when accessed via server-side rendering. The fix adds "src/static-files" to the assets array in the angular.json build configuration, ensuring these files are copied to dist/browser/static-files/ during the build process.

Changes:

  • Updated angular.json to include "src/static-files" in the build assets array, following the same pattern as existing assets like "src/assets" and "src/robots.txt"

@kosarko
Copy link
Member

kosarko commented Mar 3, 2026

@amadulhaxxani I'm not sure this works as it's supposed to. The idea was that the static pages (namely license texts) will be available to clients with no javascript support (such as curl, (e)links, or any python script).

this doesn't contain the license name

curl https://dspace-dev.ufal.mff.cuni.cz/repository/static/license-ud-1.0.html | grep "Universal Dependencies"

NOTE:
the snippet below works, but this was working before as well. the issue with this is that nobody is going to guess this url (this is not the "canonical" url we are showing

curl https://dspace-dev.ufal.mff.cuni.cz/repository/static-files/license-ud-1.0.html | grep "Universal Dependencies"
        Universal Dependencies 1.0 License Set
This file contains all licenses and description of their scope regarding Universal Dependencies 1.0.

Update HtmlContentService to compose namespaced URLs, build runtime absolute URLs when running on the server (REQUEST/PLATFORM_ID), and centralize HTTP text fetching via getHtmlContent. Ensure APP_CONFIG ui.nameSpace is respected and handle absolute URLs and existing namespace prefixes. Add comprehensive unit tests (html-content.service.spec.ts) covering namespaced/default paths, locale fallback, and error handling. Adjust static-page.component.spec.ts to use a RouterMock with configurable route and add a test asserting the service is called with the route's HTML filename.
@kosarko kosarko merged commit 4eadd8b into clarin-v7 Mar 10, 2026
8 of 9 checks passed
@port-pr
Copy link

port-pr bot commented Mar 10, 2026

Backport branch created but failed to create PR.
Request to create PR rejected with status 403.

Please create the PR manually:

Or via GitHub CLI:

gh pr create --repo dataquest-dev/dspace-angular --base dtq-dev --head ufal:backport-103-to-dtq-dev --title "[Port dtq-dev] Add src/static-files to build assets" --body "Port of #103 by @amadulhaxxani to `dtq-dev`."

(see action log for full error response)

port-pr bot pushed a commit that referenced this pull request Mar 10, 2026
* Add src/static-files to build assets

Update angular.json to include "src/static-files" in the build assets array so files placed there are copied into the build output. This ensures additional static resources are available at runtime without changing code paths.

* Support namespaced/SSR HTML loading; add tests

Update HtmlContentService to compose namespaced URLs, build runtime absolute URLs when running on the server (REQUEST/PLATFORM_ID), and centralize HTTP text fetching via getHtmlContent. Ensure APP_CONFIG ui.nameSpace is respected and handle absolute URLs and existing namespace prefixes. Add comprehensive unit tests (html-content.service.spec.ts) covering namespaced/default paths, locale fallback, and error handling. Adjust static-page.component.spec.ts to use a RouterMock with configurable route and add a test asserting the service is called with the route's HTML filename.

(cherry picked from commit 4eadd8b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render the static pages in SSR mode

3 participants