ArafatKhan2198 opened a new pull request, #1471:
URL: https://github.com/apache/knox/pull/1471

   ## **What changes were proposed in this pull request?**
   
   Apache Ozone has upgraded Recon's web server from Jetty 9.4 to Jetty 12 
(HDDS-8280, HDDS-16683). Jetty 12 serves `.js` files with Content-Type 
`text/javascript`, where Jetty 9.4 used `application/javascript`.
   
   The `OZONE-RECON/filter/staticLinks` filter in 
`[ozone-recon/1.2.0/rewrite.xml](https://app.notion.com/p/ozone-recon/1.2.0/rewrite.xml)`
 was declared only for `application/javascript`. With a Jetty 12 Recon, Knox 
finds no matching filter and passes Recon's JS through unchanged. The 
`/api/v1/...` links are never rewritten to 
`{gateway.url}/ozone-recon/api/v1/...`, so the UI loads but every API call goes 
to `https://<knox-host>:8443/api/v1/...` and fails with 404.
   
   This PR changes the filter content type to `*/javascript`, which matches 
both `application/javascript` and `text/javascript`. Knox's `MimeTypeMap` 
already supports this wildcard, and the `ozone`, `ozone-scm`, `hdfsui`, 
`hbaseui` and `hue` service definitions already use it.
   
   ## **How was this patch tested?**
   
   Manual test against a Knox gateway in front of an Ozone Recon running Jetty 
12.1.14:
   
   1. **Before the fix:** Recon served its JS as `text/javascript`. The JS 
fetched through Knox (`/gateway/<topology>/ozone-recon/static/js/index-*.js`) 
was byte-identical to the JS served directly by Recon and still contained 
`"/api/v1/clusterState"`. The Recon UI loaded through Knox, but its API calls 
failed with 404.
   2. Applied the change to the ozone-recon service definition on the Knox 
hosts and restarted Knox.
   3. Checked that the new topology deployment's `WEB-INF/rewrite.xml` 
contained `<content type="*/javascript">` for `OZONE-RECON/filter/staticLinks`.
   4. **After the fix:** the JS fetched through Knox contained 
`"https://<knox-host>:8443/gateway/<topology>/ozone-recon/api/v1/clusterState"`,
 and the Recon UI worked through Knox.
   5. Regression check: against a Recon on Jetty 9.4 (serving 
`application/javascript`), the rewrite was applied as before.
   
   I also ran Knox's `MimeTypeMap` locally with a `*/javascript` key. It 
matched `text/javascript`, `application/javascript` and `text/javascript; 
charset=utf-8`. The old `application/javascript` key did not match 
`text/javascript`.
   
   ## **Integration Tests**
   
   No integration test was added. This is a one-line change to a service 
definition. The integration suite in `.github/workflows/tests` does not run an 
Ozone Recon backend, and adding one just for this case would be a large 
addition. The wildcard matching this change relies on is already covered by 
`MimeTypeMapTest` (e.g. `*/xml`, `*/json`).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to