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
[Feature Request] 希望umi4.x支持devServer #10060
Comments
用 https://umijs.org/docs/guides/proxy 或者在插件里(比如 项目级插件)调用 import { IApi } from 'umi'
export default (api: IApi) => {
api.onBeforeMiddleware(({ app }) => {
console.log('app: ', app)
})
} |
我理解proxy是配置接口跨域的 插件的形式希望大佬多给些提示,我应该是没get到关键点,谢谢! |
我理解现在支持跨域的 https://github.com/umijs/umi/blob/master/packages/bundler-webpack/src/server/server.ts#L38 自定义的话 可以 import { IApi } from 'umi'
export default (api: IApi) => {
api.onBeforeMiddleware(({ app }) => {
app.use(helloMiddleware)
})
} |
我也遇到了相同的问题,其他开发者启动项目并不支持跨域,目前正在定位问题。 |
你好,请问你是怎么解决的,我现在本地接qiankun有碰到这个问题 |
同求,子应用场景 |
@spencerswagger @adrestios @hyzx86 非常抱歉回复晚了 |
@JJH0901 谢谢你的经验分享 |
给后来者参考如何解决跨域问题 可以通过在根目录创建 plugin.ts,内容如下: import type { IApi } from 'umi';
export default (api: IApi) => {
// 中间件支持 cors
api.addMiddlewares(()=>{
return function cors(
req,
res,
next,
) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', '*');
next();
}
});
}; |
参考 devServer 选项怎么配置 ,通过一些配置,理论上可以支持你想要的任何行为。 |
umi 4.0.72 里 没效果 |
没有devServer 启动开发服务器时自动打开浏览器{open:true} 怎么配置呢 |
不支持自动打开浏览器,可以自己写一个启动的脚本,使用 |
Background
新项目主应用使用umi4,子应用使用umi max
开发环境中,主应用访问子应用会跨域
希望可以支持devServer,设置headers:{'Access-Control-Allow-Origin':'*'},允许主应用跨域访问子应用
Proposal
umi4.x继续支持umi3.x中的devServer配置
The text was updated successfully, but these errors were encountered: