-
Notifications
You must be signed in to change notification settings - Fork 12
dispatcher
crossjs edited this page Dec 8, 2015
·
4 revisions
目的
- 为了兼容 IE 8/9(它们不支持 CORS,所以需要本地服务器代理)
- 为了做需要 Bearer token 能做的事(有些接口出于安全考虑,不支持通过 Mac token 方式访问)
流程
- 用户通过 REST 向最终目标接口发起请求;
- REST 查找 Dispatcher 配置,决定是直接访问,还是通过本地 Dispatcher 接口实现代理访问。
相关配置
/**
* @constant {object} 接口请求代理配置,设置为 null 不走代理
*/
const DISPATCHER = {
// 只代理白名单资源
// 设置为 null 则全部走代理
// whitelist: [UC_RES],
// whitelist: [MB_RES],
res: LOC_RES,
api: 'dispatcher'
}
开发调试
- dev server 提供了 dispatcher 中间件
- 你只需要在根目录下创建一个文件 .shouldnotpublic
- 小心!不要将密码暴露在不安全的环境中!
export default {
login_name: 'login name like abc@xyz',
password: 'password encrypted with md5'
}