thx / rap2-dolores

MIT License
610 stars 255 forks source link

生成的接口地址不能访问-解决方法 #30

Closed deepcc closed 6 years ago

deepcc commented 6 years ago

页面链接:http://localhost:3000/repository/editor?id=14 点击“地址”:http://127.0.0.1:8080/app/mock/14/GET//example/1523240738732 出现: { "isOk": false, "errMsg": "未匹配到任何接口 No matched interface" }

原因:链接中传入了接口类型

解决方法1(前端去掉接口类型): \rap2-dolores\src\components\editor\InterfaceSummary.jsx 42行改为: <Link to={${serve}/app/mock/${repository.id}${itf.url}} target='_blank'>{itf.url}

方法2(后端过滤接口类型): \rap2-delos\src\routes\utils\url.ts 25行:urlMatchesPattern方法中过滤接口类型 url = url.replace(/^\/?(get|post|put|delete)\//i, '')

个人认为前端去掉接口类型比较好,影响了后台逻辑和效率

ruoxiaojie commented 6 years ago

上面有个测试按钮也不能用 有解决吗?

deepcc commented 6 years ago

@ruoxiaojie 方法2(后端过滤接口类型): \rap2-delos\src\routes\utils\url.ts 25行:urlMatchesPattern方法中过滤接口类型 url = url.replace(/^\/?(get|post|put|delete)\//i, '')

ruoxiaojie commented 6 years ago

o ,我只改了前端 原来后端这个也要改 谢谢了

Bosn commented 6 years ago

fixed