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

mock如果切换到真实服务器请求(回答不要贴文档) #7015

Closed
Liqiankun opened this issue Jul 15, 2020 · 14 comments
Closed

mock如果切换到真实服务器请求(回答不要贴文档) #7015

Liqiankun opened this issue Jul 15, 2020 · 14 comments

Comments

@Liqiankun
Copy link

💻 示例代码

dev: {
    '/api': {
      target: 'https://my.api.call/',
      changeOrigin: true,
      pathRewrite: {
        '^/api': '',
      },
    },
  }

截屏2020-07-15 14 11 06

@afc163
Copy link
Member

afc163 commented Jul 15, 2020

你不是搞明白了么:#2303 (comment)

@Liqiankun
Copy link
Author

是的,但是现在又不明白了。@afc163 我本地调试应该是可以的,但是现在还是去本地的API

@afc163
Copy link
Member

afc163 commented Jul 15, 2020

#5795 (comment)

做做个人知识沉淀吧,一条河流踏进去两次。

@afc163 afc163 closed this as completed Jul 15, 2020
@Liqiankun
Copy link
Author

@afc163 这个是部署之后的,我这个是本地开发,测试环境,而且是按照上次的方法设置的还是不行。

@Liqiankun
Copy link
Author

Liqiankun commented Jul 15, 2020

截屏2020-07-15 14 43 15
@afc163 这个地方应该不是或吧?

@afc163
Copy link
Member

afc163 commented Jul 15, 2020

本地开发用 proxy,就是你主楼里的用法。

@Liqiankun
Copy link
Author

Liqiankun commented Jul 15, 2020

@afc163 但是从我实践的角度来说,应该是设置proxy && npm run start:no-mock才能在本地开发中链接到真实的服务器。@afc163 如果我理解错了请纠正!

@afc163
Copy link
Member

afc163 commented Jul 15, 2020

实测不需要,proxy + npm start 就可以反向代理到真实服务器了。

@Liqiankun
Copy link
Author

@afc163 你说完之后我又测试了一下。可能是因为我没有重新npm start

afc163 added a commit to ant-design/ant-design-pro-site that referenced this issue Jul 15, 2020
@afc163
Copy link
Member

afc163 commented Jul 15, 2020

补充了一些文档:ant-design/ant-design-pro-site@f51145b

chenshuai2144 pushed a commit to ant-design/ant-design-pro-site that referenced this issue Jul 16, 2020
* style: optimize site style

* test: fix eslint

* update bigfish url

* Add FAQ link of umi

* document about proxy config

close ant-design/ant-design-pro#7015

* Rename antd-4.0.en-Us.md to antd-4.0.en-US.md

* update prolayout url

* move layout-component into layout

* fix document order
@xz9876
Copy link

xz9876 commented Jul 17, 2020

补充了一些文档:ant-design/ant-design-pro-site@f51145b

不好意思 我的实测不起作用啊 改了proxy和用npm start, 这个方法并没有连接到我给的Api地址

@afc163
Copy link
Member

afc163 commented Jul 20, 2020

image

@kennylbj
Copy link
Contributor

在V5里,开启了proxy + yarn start,如果mock里有相同的url,会优先使用Mock数据。

能否优先进行反向代理?

@CheaterScript
Copy link

在V5里,开启了proxy + yarn start,如果mock里有相同的url,会优先使用Mock数据。

能否优先进行反向代理?

同样的问题,求解

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants