Ant-design-pro: 从mock切换至后端服务器没有效果

Created on 6 Nov 2017  ·  3Comments  ·  Source: ant-design/ant-design-pro

后端是java服务器。

按照教程修改.roadhogrc.mock.js如下:
// export default noProxy ? {
// 'GET /api/*': 'http://localhost:8080/api/',
// } : delay(proxy, 1000);

export default { 'GET /api/*': 'http://localhost:8080/api/', };

从chrome的network上能看到请求的是下面地址:
http://localhost:8000/api/jwt/auth
实际上是想转到
http://localhost:8080/api/jwt/auth

但是实际上没有,始终提示404. 后端服务器也没有收到消息
http://localhost:8080/api/jwt/auth 这个地址我使用postman已经测试能返回正确值。

请问该如何判断是否配置问题?还是其他原因

Most helpful comment

原因找到了。是因为

export default { 'GET /api/*': 'http://localhost:8080/api/', } 

这么配置后,路径会转到 http://localhost:8080/api/api/jwt/auth

其实就是多了个 api 路径, 实际上要改为

export default { 'GET /api/*': 'http://localhost:8080/', } 

这个地方很误导人。 留个记录给后来人避免踩坑吧。

All 3 comments

原因找到了。是因为

export default { 'GET /api/*': 'http://localhost:8080/api/', } 

这么配置后,路径会转到 http://localhost:8080/api/api/jwt/auth

其实就是多了个 api 路径, 实际上要改为

export default { 'GET /api/*': 'http://localhost:8080/', } 

这个地方很误导人。 留个记录给后来人避免踩坑吧。

@nikogu 文档是不是要改下?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gaoqiang19514 picture gaoqiang19514  ·  3Comments

zhuanglong picture zhuanglong  ·  3Comments

happier2 picture happier2  ·  3Comments

952425340 picture 952425340  ·  3Comments

yanjc39 picture yanjc39  ·  3Comments