thx / rap2-dolores

MIT License
610 stars 255 forks source link

docker容器内部署delos模块在经过nginx反向代理后无法匹配接口 #23

Closed fly2leoo closed 6 years ago

fly2leoo commented 6 years ago

dolores模块页面访问正常,可以成功注册、登录,并可以进行接口新增和修改,但是请求接口时却无法匹配接口

请求例示 http://rest.mock.domain.com/app/mock/16/GET/example/1520095481062 返回结果如下 { "isOk": false, "errMsg": "未匹配到任何接口 No matched interface" }

Docker容器使用官方镜像创建docker.io/node,映射内部8080端口 docker run -it -d -p 39999:8080 993f38da6c6c 直接使用node启动模块 docker exec -d 9603945a7fcd node /home/node/rap2-delos/dist/dispatch.js

反向代理匹配如下 server { listen 80; server_name rest.mock.domain.com; location / { proxy_pass http://127.0.0.1:39999; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }

dolores模块使用nginx单独部署 server { listen 80; server_name rap2.domain.com; location / { root /var/www/html/rap2; index index.html; } }

fly2leoo commented 6 years ago

本地部署也有同样的问题,例如以下请求 http://127.0.0.1:8080/app/mock/16/GET/example/1520095481062 得到结果{ "isOk": false, "errMsg": "未匹配到任何接口 No matched interface" }

fly2leoo commented 6 years ago

好吧... 问题已解决

dolores模块,src/component/editor/InterfaceSummary.jsx Line 42: <Link to={${serve}/app/mock/${repository.id}/${itf.method}/${itf.url}} target='_blank'>{itf.url}

把变量${itf.method}/ 删除掉,然后重新编译

alvarto commented 6 years ago

问题的核心在于 rap2 为了支持 restful 的接口设计,会在mock时加入method,但在某个更新之后引入了bug导致method匹配不上了。

lokikyou commented 6 years ago

补充一下,测试按钮需要改rap2-delos中的文件 public/libs/jquery.rap.js 将41行中的${match.method}给去掉

Bosn commented 6 years ago

fixed