Add src/static-files to build assets#103
Conversation
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.
There was a problem hiding this comment.
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"
|
@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 NOTE: |
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.
|
Backport branch created but failed to create PR. 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) |
* 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)
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