VSB-TUO/fix(static-page): return HTTP 404 for missing static pages - #1460
Merged
Conversation
StaticPageComponent rendered an empty shell and answered HTTP 200 when a `/static/<file>` page did not exist: it tried to load `static-files/error.html` and, when that was empty/missing, showed nothing and never set a 404 status. UNIVERSAL-016 (dspace-ui-tests notFoundPage.spec.ts) therefore failed on the "non-existent static page shows 404 page" case. Set the SSR response to 404 via ServerResponseService and render the inline 404 page (same markup + reused `404.*` i18n keys as PageNotFoundComponent) when the content is not found. Drop the legacy error.html loading path. Behaviour now matches dtq-dev: /static/<missing> returns 404 with the "404 / Take me to the home page" page. Refs dataquest-dev/dspace-customers#566 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect HTTP 200 responses for missing /static/<page> routes by explicitly switching to a 404 SSR response and rendering an inline 404 view when the requested static HTML file can’t be loaded.
Changes:
- Add a
contentState(loading/found/not-found) to drive UI rendering for static pages, including an inline 404 view. - Set SSR response status to 404 via
ServerResponseService.setNotFound()when static content is missing. - Update the unit test to provide
ServerResponseServiceand assert the not-found behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/app/static-page/static-page.component.ts |
Adds SSR 404 signaling and state-driven rendering for missing static content. |
src/app/static-page/static-page.component.html |
Introduces loading / content / inline-404 template branches. |
src/app/static-page/static-page.component.spec.ts |
Extends tests to cover the new not-found behavior and SSR status call. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…yped spy - Add role="link" tabindex="0" to the inline 404 home link so it matches PageNotFoundComponent (same as dtq-dev), per Copilot review. - Type the HtmlContentService test spy as jasmine.SpyObj<HtmlContentService> instead of `any`. Refs dataquest-dev/dspace-customers#566 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
milanmajchrak
approved these changes
Aug 19, 2026
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.
Problem
/static/<missing>answered HTTP 200 with an empty shell instead of a 404 page.StaticPageComponenttried to loadstatic-files/error.htmland, when that was empty/missing, rendered nothing and never set a 404 status. UNIVERSAL-016 (dspace-ui-testsnotFoundPage.spec.ts→ non-existent static page shows 404 page) failed on this instance, while dtq-dev returns a proper 404.Fix
ServerResponseService.setNotFound()when the static file is not found.404.*i18n keys asPageNotFoundComponent) via acontentState(loading/found/not-found).error.htmlloading path.ServerResponseService, add a not-found test).Mirrors the verified dtq-dev fix (
f8495ea85c) on the same Angular 15 base.Result
/static/<missing>now returns HTTP 404 with the "404 / Take me to the home page" page — matching dtq-dev. Verified locally with an AOTng build(development) on thesavbranch (identical change across all four customers).Refs dataquest-dev/dspace-customers#566
🤖 Generated with Claude Code