Skip to content

[ISSUE #390] Fix unable to add ProxyAddr by aligning frontend/backend parameter binding#422

Closed
messere1 wants to merge 2 commits into
apache:masterfrom
messere1:contest/bugfix-pr02-proxy-addr
Closed

[ISSUE #390] Fix unable to add ProxyAddr by aligning frontend/backend parameter binding#422
messere1 wants to merge 2 commits into
apache:masterfrom
messere1:contest/bugfix-pr02-proxy-addr

Conversation

@messere1

@messere1 messere1 commented Jul 8, 2026

Copy link
Copy Markdown

What is the purpose of the change

Fix #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:

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

  • Make sure there is a Github issue filed for the change.
  • Format the pull request title like [ISSUE #390] Fix ....
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction.
  • Run mvn clean install -DskipITs to make sure unit-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

…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
Copilot AI review requested due to automatic review settings July 8, 2026 09:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 ProxyController to bind addProxyAddr / updateProxyAddr parameters from JSON bodies (@RequestBody) instead of query/form parameters (@RequestParam).
  • Fixed _fetch header spread order in remoteApi.js and updated addProxyAddr to send JSON instead of application/x-www-form-urlencoded.
  • Added a new ProxyControllerTest covering 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>
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale label Jul 18, 2026
@github-actions github-actions Bot closed this Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

无法添加 ProxyAddr

2 participants