翻译:
Jsonp 支持的鸡蛋插件 .
使用量
彩蛋内置插件 jsonp 默认启用.
// {app_root}/config/plugin.ts
export default {
jsonp: {
enable: true,
},
};
配置
- {String{Array} 回调 - jsonp 回调方法密钥,默认为
[ '_callback', 'callback' ] - {编号} 限制 - 回调方法名称的最大长度, 默认为
50 - csrf - 允许csrf检查与否. 默认为虚假
- {String}RegExp{Array} 白名单 - 裁判员白名单
若为白色 列表类型是 RegExp,裁判员必须匹配 whiteList,注意第一个 ^ 最后一个 /。 。 。 .
export default {
jsonp: {
whiteList: /^https?:\/\/test.com\//,
},
};
// matchs referrer:
// https://test.com/hello
// http://test.com/
若为白色 列表类型是 String 开始 .数字 :
export default {
jsonp: {
whiteList: '.test.com',
},
};
// matchs domain test.com:
// https://test.com/hello
// http://test.com/
// matchs subdomain
// https://sub.test.com/hello
// http://sub.sub.test.com/
若为白色 列表类型是 String 而不是从 .数字 :
export default {
jsonp: {
whiteList: 'sub.test.com',
},
};
// only matchs domain sub.test.com:
// https://sub.test.com/hello
// http://sub.test.com/
白色列表也可以是一个阵列:
export default {
jsonp: {
whiteList: ['.foo.com', '.bar.com'],
},
};
见 配置/ 配置. 默认. ts 更详细.
API 密码
- ctx.acceptJSONP (中文(简体) ). - 检测答复是否为jsonp,只读
示例
标准应用程序使用
单位 app/router.ts
// Create once and use in any router you want to support jsonp.
const jsonp = app.jsonp();
app.get('/default', jsonp, 'jsonp.index');
app.get('/another', jsonp, 'jsonp.another');
// Customize by create another jsonp middleware with specific configurations.
app.get('/customize', app.jsonp({ callback: 'fn' }), 'jsonp.customize');
teg Http 控制器使用量
TOD: TBD 数据
问题和建议
请打开一个问题 这里。 。 。 .
许可证
贡献者
制造的 贡献者-img。 。 。 .