fix: return 200 for CDA GUI client routes - #1871
Conversation
Signed-off-by: Charles Graham, SWT <charles.r.graham@usace.army.mil>
| /** | ||
| * Converts the error dispatch used to load known client-side routes into a successful response. | ||
| */ | ||
| public final class SpaErrorStatusFilter implements Filter { |
There was a problem hiding this comment.
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.
Signed-off-by: Charles Graham, SWT <charles.r.graham@usace.army.mil>
|
@MikeNeilson I had initially planned to go in this direction, but I pushed up this older idea for handling the routing before our group had landed on splitting the UI and the API. Would you be okay with me updating this PR, opening a new PR, or opening a PR against this PR with a new proposed method for splitting the two? One possibility is to produce two independently deployed WARs/applications: one for the UI and one for the API. That could require districts to install and manage two different WARs. Would that separation be a better option now that we have the new update script, or would the additional deployment be more trouble than it is worth? |
Hmm, might be more trouble than it's worth, but reasonable to investigate. Would want them both as WARs to easy the packaging but we'll see how much of a problem it is in the docker compose setup and tests, oh look at how OpenDCS does it. they are separate there. so yeah not a huge deal. I think we'll need a WAF change in prod and test, but that's not a huge deal if we know it's coming. |
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 ofhttps://cwms-data.usace.army.mil/cwms-data being the UI and APIhttps://cwms-data.usace.army.mil -> UIhttps://cwms-data.usace.army.mil/cwms-data -> APIAdditional comment added below.
Summary
Root Cause
Tomcat routes missing static resources through the
404error-page mapping toindex.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
GETandHEADroutes. 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 classesChecklist