Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Incorrect api path in specific configuration #5057

Closed
1 task done
kerwin612 opened this issue Aug 21, 2023 · 0 comments · Fixed by #5058
Closed
1 task done

[BUG] Incorrect api path in specific configuration #5057

kerwin612 opened this issue Aug 21, 2023 · 0 comments · Fixed by #5058
Assignees
Labels
type: bug Something isn't working

Comments

@kerwin612
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In the springmvc project, after adding the configuration of spring.mvc.servlet.path or server.servlet.context-path, the API path registered to the gateway is incorrect

Expected Behavior

Expect to register the correct API path to the gateway

Steps To Reproduce

  1. git clone shenyu@master
  2. edit shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml
  3. launch admin and bootstrap and shenyu-examples-springmvc
  4. debug api in admin dashboard.

diff shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml

diff --git a/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml b/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml
index 9fb5a6a..a7d5386 100644
--- a/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml
+++ b/shenyu-examples/shenyu-examples-springmvc/src/main/resources/application.yml
@@ -17,13 +17,17 @@ server:
   port: 8289
   address: 0.0.0.0
   servlet:
-    context-path: /
+    context-path: /test
   tomcat:
     max-http-form-post-size: 100MB
+
 spring:
+  mvc:
+    servlet:
+      path: /api

The curl of the debugging API is as follows:

curl 'http://127.0.0.1:9095/sandbox/proxyGateway' \
  -H 'Accept: */*' \
  -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Cookie: JSESSIONID=BCC29CACFEF7B48C101FA3EB293F6970' \
  -H 'Origin: http://127.0.0.1:9095' \
  -H 'Pragma: no-cache' \
  -H 'Referer: http://127.0.0.1:9095/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203' \
  -H 'X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjkyNjE3ODc4fQ.Yb8G12vZDNBPtZzi9cVzy29cv6lBdoTnh8JVr4Ycc7c' \
  -H 'sec-ch-ua: "Not/A)Brand";v="99", "Microsoft Edge";v="115", "Chromium";v="115"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  --data-raw '{"httpMethod":"GET","querys":"{}","bizParam":{},"headers":{"Content-type":"application/x-www-form-urlencoded"},"requestUrl":"http://127.0.0.1:9195/mvc/order/findById"}' \
  --compressed

response error:

<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1></body></html>

Environment

ShenYu version(s): master

Debug logs

[shenyu-netty-nio-3] INFO  org.apache.shenyu.plugin.base.AbstractShenyuPlugin - contextPath selector match success from default strategy
[shenyu-netty-nio-3] INFO  org.apache.shenyu.plugin.base.AbstractShenyuPlugin - contextPath selector success match , selector name :/mvc
[shenyu-netty-nio-3] INFO  org.apache.shenyu.plugin.base.AbstractShenyuPlugin - contextPath rule success match , rule name :/mvc
[shenyu-netty-nio-3] INFO  org.apache.shenyu.plugin.base.AbstractShenyuPlugin - divide selector match success from default strategy
[shenyu-netty-nio-3] INFO  org.apache.shenyu.plugin.base.AbstractShenyuPlugin - divide selector success match , selector name :/mvc
[shenyu-netty-nio-3] INFO  org.apache.shenyu.plugin.base.AbstractShenyuPlugin - divide rule success match , rule name :/mvc/order/findById
[shenyu-netty-nio-3] DEBUG org.apache.shenyu.plugin.httpclient.AbstractHttpClientPlugin - The request urlPath is: http://192.168.56.1:8289/order/findById, retryTimes is : 3, retryStrategy is : current

Anything else?

Spring Web MVC - Path Matching

Context Path vs. Servlet Path in Spring

@kerwin612 kerwin612 added the type: bug Something isn't working label Aug 21, 2023
@kerwin612 kerwin612 mentioned this issue Aug 21, 2023
3 tasks
moremind added a commit that referenced this issue Sep 8, 2023
* Added support for enabling debug logs for okhttp

* Create LICENSE-logging-interceptor.txt

* Fix incorrect api path in specific configuration

* fixed tests error

---------

Co-authored-by: dragon-zhang <zhangzicheng@apache.org>
Co-authored-by: yunlongn <yunlongn@outlook.com>
Co-authored-by: moremind <hefengen@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants