您现在的位置是:网站首页>软件开发>开发终端>yii2yii2
Class yii\filters\Cors ----CORS 跨域资源共享控制筛选器
风口下的猪2023-03-14【yii2】
简介
CORS 筛选器作为行为附加到控制器或模块来使用 CORS 筛选器
public function behaviors()
{
return [
'corsFilter' => [
'class' => \yii\filters\Cors::className(),
'cors' => [
// restrict access to
'Origin' => ['http://www.myserver.com', 'https://www.myserver.com'],
// Allow only POST and PUT methods
'Access-Control-Request-Method' => ['POST', 'PUT'],
// Allow only headers 'X-Wsse'
'Access-Control-Request-Headers' => ['X-Wsse'],
// Allow credentials (cookies, authorization headers, etc.) to be exposed to the browser
'Access-Control-Allow-Credentials' => true,
// Allow OPTIONS caching
'Access-Control-Max-Age' => 3600,
// Allow the X-Pagination-Current-Page header to be exposed to the browser.
'Access-Control-Expose-Headers' => ['X-Pagination-Current-Page'],
],
],
];
}
Cors筛选器一般用于behavior
很赞哦! (0)
/ponder/index.php/index/catelist/catelist/cateid/10.html
相关阅读 (同一栏目)
- yii控制器及路由
- Class yii\filters\VerbFilter ----操作过滤器
- Class yii\filters\Cors ----CORS 跨域资源共享控制筛选器
- Class yii\filters\auth\CompositeAuth
- Class yii\filters\auth\HttpBearerAuth
- yii2请求获取参数
- yii2目录结构说明
- yii2 系统定义的路径别名
- yii2模型中attributeLabels()的作用
- yii2模型中定义对应数据库和验证规则
- yii2模型中块赋值$model -> attributes = $data;
- 理解yii2模型中findOne()、findAll()
- yii2模型增加数据
- yii2模型修改数据
- yii2模型删除数据
- yii2实现多个不同数据库连接
- yii2连接sqlsever的一些注意点 (windows解法)
- yii2和tp链式查询时where的区别
- yii2 关联查询总结
栏目目录
标签云
站点信息
- 文章统计:528篇
- 移动端访问:扫码进入SQ3R
