[ISSUE #390] Fix unable to add ProxyAddr by aligning frontend/backend parameter binding#422
Closed
messere1 wants to merge 2 commits into
Closed
[ISSUE #390] Fix unable to add ProxyAddr by aligning frontend/backend parameter binding#422messere1 wants to merge 2 commits into
messere1 wants to merge 2 commits into
Conversation
…ackend parameter binding - Change ProxyController addProxyAddr/updateProxyAddr from @RequestParam to @RequestBody Map<String,String> - Fix _fetch header spread order so caller Content-Type is respected - Change addProxyAddr frontend to send JSON body instead of URL-encoded form
There was a problem hiding this comment.
Pull request overview
This PR fixes Issue #390 by making the frontend and backend agree on how ProxyAddr parameters are sent/bound (JSON request body), and by correcting the frontend _fetch header merge order so callers can override default headers when needed.
Changes:
- Updated
ProxyControllerto bindaddProxyAddr/updateProxyAddrparameters from JSON bodies (@RequestBody) instead of query/form parameters (@RequestParam). - Fixed
_fetchheader spread order inremoteApi.jsand updatedaddProxyAddrto send JSON instead ofapplication/x-www-form-urlencoded. - Added a new
ProxyControllerTestcovering homepage + JSON POSTs for add/update endpoints.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/main/java/org/apache/rocketmq/dashboard/controller/ProxyController.java | Switches add/update endpoints to JSON body binding via @RequestBody. |
| frontend-new/src/api/remoteApi/remoteApi.js | Fixes header precedence in _fetch and sends JSON body for addProxyAddr. |
| src/test/java/org/apache/rocketmq/dashboard/controller/ProxyControllerTest.java | Adds controller tests for homepage + JSON POST binding for add/update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
This pull request has been automatically closed because there has been no activity for 7 days. If you would like to continue working on this, please reopen the PR with updated changes. |
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.
What is the purpose of the change
Fix #390 — users are unable to add a ProxyAddr in the dashboard UI.
Root cause: The frontend
addProxyAddrAPI sends a JSON request body (Content-Type: application/json), but the backendProxyController.addProxyAddruses@RequestParam, which only binds query/form parameters — not JSON body. The two sides never agree on the parameter binding format.Additionally, the
_fetchutility inremoteApi.jshas a header-merge order bug:{...options.headers, 'Content-Type': 'application/json'}always overwrites any caller-suppliedContent-Type, so even if a caller setsapplication/x-www-form-urlencoded, it gets clobbered.Brief changelog
ProxyController.java— ChangedaddProxyAddrandupdateProxyAddrfrom@RequestParam Stringto@RequestBody Map<String, String>, so the controller accepts JSON request bodies sent by the frontend.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.remoteApi.js(addProxyAddr) — Changed fromURLSearchParamsform body toJSON.stringify({newProxyAddr})to match the new@RequestBodybackend contract.ProxyControllerTest.java(new) — Added 3 unit tests:testHomePage,testAddProxyAddr(POST with JSON body),testUpdateProxyAddr(POST with JSON body).Verifying this change
Run unit tests:
mvn test -Dtest=ProxyControllerTestAll 3 tests pass:
Manual verification:
127.0.0.1:8081).Checklist
[ISSUE #390] Fix ....mvn clean install -DskipITsto make sure unit-test pass.