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

👑 [需求] 怎么在文档中使用代理 #61

Closed
OxPatient opened this issue Jan 15, 2020 · 4 comments
Closed

👑 [需求] 怎么在文档中使用代理 #61

OxPatient opened this issue Jan 15, 2020 · 4 comments

Comments

@OxPatient
Copy link

🥰 需求描述

在文档中,组件需要访问API获取数据进行渲染,请问如何在father-doc中设置代码

@xiaohuoni
Copy link
Member

理论上应该可以通过proxy配置请求。

@OxPatient
Copy link
Author

使用UMI配置可行

@amyhuangxbd
Copy link

使用UMI配置可行

我在.umirc.ts 中配置proxy 还是没有成功
`import { defineConfig } from 'dumi';

const os = require("os");
const ifaces = os.networkInterfaces();

export const getHost = () => {
let host = '127.0.0.1';
let hasFound = false

for (const dev in ifaces) {
ifaces[dev].forEach(function(details) {
if(hasFound) return
if (details.family === 'IPv4' && details.address.indexOf('192.168') >= 0) {
host = details.address;
hasFound=true
}
});
}

return host;
};

export default defineConfig({
title: 'trialos-ui-common',
outputPath: 'docs-dist',
proxy: {
'/api': {
'target': 'http://xxx.test.com',
'changeOrigin': true,
'pathRewrite': { '^/$': '', },
cookieDomainRewrite: getHost(),
},
},
extraBabelPlugins: [
['babel-plugin-import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
}],
],
});
`
你是怎么配置的?

@tancyan
Copy link

tancyan commented Apr 27, 2021

请问这个问题为什么会关闭呀?最终怎么解决么?
proxy仅在dev生效呀,线上部署的doc怎么能用proxy呢?

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

No branches or pull requests

4 participants