This is an automated email from the ASF dual-hosted git repository.

likeguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 655d59a9 fixed #310 (#311)
655d59a9 is described below

commit 655d59a94350130c52db2dcbf3f873df76d416be
Author: Kerwin Bryant <[email protected]>
AuthorDate: Mon Aug 14 23:03:24 2023 +0800

    fixed #310 (#311)
    
    * Fixed the wrong request header
    
    * fixed #310
    
    fixed #310
---
 src/routes/Document/components/ApiDebug.js | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/routes/Document/components/ApiDebug.js 
b/src/routes/Document/components/ApiDebug.js
index faab4a5b..00543859 100644
--- a/src/routes/Document/components/ApiDebug.js
+++ b/src/routes/Document/components/ApiDebug.js
@@ -60,6 +60,10 @@ const FCForm = forwardRef(({ form, onSubmit }, ref) => {
   });
   const [activeKey, setActiveKey] = useState("1");
 
+  const getDefaultHeaderByKey = (key) => {
+    return {"Content-Type": key === '1' ? "application/json" : 
"application/x-www-form-urlencoded"}
+  }
+
   useEffect(
     () => {
       setInitialValue({
@@ -95,7 +99,7 @@ const FCForm = forwardRef(({ form, onSubmit }, ref) => {
 
   useEffect(
     () => {
-      form.setFieldsValue({headers: initialValue.header || "{}"})
+      form.setFieldsValue({headers: initialValue.header || 
JSON.stringify(getDefaultHeaderByKey(activeKey))})
     },
     [initialValue.header]
   );
@@ -187,8 +191,8 @@ const FCForm = forwardRef(({ form, onSubmit }, ref) => {
   const changeParamTab = (key) => {
     setActiveKey(key);
     let header = form.getFieldsValue().headers;
-    let headerJson = {...JSON.parse(header), "Content-type": key === '1' ? 
"application/json" : "application/x-www-form-urlencoded"};
-    setInitialValue({...initialValue, header: JSON.stringify(headerJson)})
+    let headerJson = {...JSON.parse(header), ...getDefaultHeaderByKey(key)};
+    setInitialValue({...initialValue, header: JSON.stringify(headerJson)});
   }
 
   return (

Reply via email to