8082访问/example/ping正常,:8081访问/example/ping Not Found
来源:3-14 项目打包发布(下)

404_
2023-04-25
直接访问后端 没有问题 http://192.168.2.53:8082/example/ping
但是我发现 在前端向后端发送请求的时候,url怎么会被添加了一个prod-api,变成了**/prod-api/example/ping**,后端肯定没有这个URL呀?不知道为什么会变成这样?
这个是访问的时候的日志:
kubeimooc-server | [GIN] 2023/04/25 - 09:28:05 | 404 | 117.408µs | 192.168.2.114 | GET "/prod-api/example/ping"
kubeimooc-web | 192.168.2.114 - - [25/Apr/2023:09:28:05 +0000] "GET /prod-api/example/ping HTTP/1.1" 404 18 "http://192.168.2.53:8081/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" "-"
我前端不太行,请老师予以指点
写回答
1回答
-
404_
提问者
2023-04-25
临时解决方案,修改后端example router配置。但是还是想知道为什么url前面会多出一个prod-api,导致404
root@k8s-harbor1:/apps/kubeimooc_install/kubeimooc-server/router/example# cat router.go package example import ( "github.com/gin-gonic/gin" "kubeimooc.com/api" ) type ExampleRouter struct { } func (e *ExampleRouter) InitExample(r *gin.Engine) { group := r.Group("/prod-api/example") 在url前面补上了prod-api apiGroup := api.ApiGroupApp.ExampleApiGroup group.GET("/ping", apiGroup.ExampleTest) }
00
相似问题