messere1 opened a new pull request, #422: URL: https://github.com/apache/rocketmq-dashboard/pull/422
## What is the purpose of the change Fix [#390](https://github.com/apache/rocketmq-dashboard/issues/390) — users are unable to add a ProxyAddr in the dashboard UI. **Root cause:** The frontend `addProxyAddr` API sends a JSON request body (`Content-Type: application/json`), but the backend `ProxyController.addProxyAddr` uses `@RequestParam`, which only binds query/form parameters — not JSON body. The two sides never agree on the parameter binding format. Additionally, the `_fetch` utility in `remoteApi.js` has a header-merge order bug: `{...options.headers, 'Content-Type': 'application/json'}` always overwrites any caller-supplied `Content-Type`, so even if a caller sets `application/x-www-form-urlencoded`, it gets clobbered. ## Brief changelog 1. **`ProxyController.java`** — Changed `addProxyAddr` and `updateProxyAddr` from `@RequestParam String` to `@RequestBody Map<String, String>`, so the controller accepts JSON request bodies sent by the frontend. 2. **`remoteApi.js` (`_fetch`)** — Fixed header spread order from `{...options.headers, 'Content-Type': 'application/json'}` to `{'Content-Type': 'application/json', ...options.headers}`, so caller-provided headers take precedence. 3. **`remoteApi.js` (`addProxyAddr`)** — Changed from `URLSearchParams` form body to `JSON.stringify({newProxyAddr})` to match the new `@RequestBody` backend contract. 4. **`ProxyControllerTest.java`** (new) — Added 3 unit tests: `testHomePage`, `testAddProxyAddr` (POST with JSON body), `testUpdateProxyAddr` (POST with JSON body). ## Verifying this change Run unit tests: ```bash mvn test -Dtest=ProxyControllerTest ``` All 3 tests pass: ``` Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 ``` Manual verification: 1. Start dashboard, navigate to Proxy page. 2. Click "Add ProxyAddr", enter a valid address (e.g. `127.0.0.1:8081`). 3. The address should be added successfully without errors. ## Checklist - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change. - [x] Format the pull request title like `[ISSUE #390] Fix ...`. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. - [x] Run `mvn clean install -DskipITs` to make sure unit-test pass. - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas). -- 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]
