Skip to content

fix: return 200 for CDA GUI client routes - #1871

Open
krowvin wants to merge 1 commit into
developfrom
fix/1687-spa-routing-status
Open

fix: return 200 for CDA GUI client routes#1871
krowvin wants to merge 1 commit into
developfrom
fix/1687-spa-routing-status

Conversation

@krowvin

@krowvin krowvin commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

I had been sitting on this branch for a minute and thought I would go ahead and PR it.

See Daniel's reported issue for details

Infra was setup i believe to support having CDA's UI and API being split.

instead of
https://cwms-data.usace.army.mil/cwms-data being the UI and API

https://cwms-data.usace.army.mil -> UI
https://cwms-data.usace.army.mil/cwms-dat -> API

Summary

  • return HTTP 200 when known CDA GUI routes are served through the React client-side routing fallback
  • preserve the existing 404 status for unknown paths and non-page requests
  • support alternate CDA deployment context paths and trailing-slash navigation

Root Cause

Tomcat routes missing static resources through the 404 error-page mapping to index.html. The React app therefore renders successfully, but the original 404 status remains on the response. Reverse proxies and web crawlers treat that successful page as missing.

The new error-dispatch filter changes the status only for known GUI GET and HEAD routes. API and unknown-route 404 behavior is left intact.

Related Issue

Closes #1687

Validation

  • ./gradlew :cwms-data-api:test --tests 'cwms.cda.servlet.SpaErrorStatusFilterTest' — 13 passed
  • ./gradlew :cwms-data-api:checkstyleMain :cwms-data-api:checkstyleTest :cwms-data-api:test --tests 'cwms.cda.servlet.SpaErrorStatusFilterTest' — passed; the new files have no Checkstyle findings
  • ./gradlew build — compilation, GUI build, WAR packaging, and 745 tests passed; the test task failed on 9 existing Mockito failures under local JDK 21 while mocking generated/final classes
  • Integration tests were not run because this routing change does not require Oracle/CWMS infrastructure

Checklist

  • AI tools used

@krowvin
krowvin marked this pull request as ready for review August 8, 2026 01:34
@krowvin
krowvin requested a review from MikeNeilson August 8, 2026 01:34
/**
* Converts the error dispatch used to load known client-side routes into a successful response.
*/
public final class SpaErrorStatusFilter implements Filter {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add @WebFilter (I think, look at the other filters for the right annotation) and remove the web.xml change.

Unless there's a specific reason to configure it in the web.xml instead. That recommendation is likely left over from all the examples that existed before annotations were supported in Java.

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.

Swagger page returns 404 but loads anyway

2 participants