pagemachine/cors
此包已被弃用,不再维护。未建议替代包。
TYPO3 CMS 的跨源资源共享。
2.0.6
2018-05-11 08:05 UTC
Requires
- php: ^5.6 || ^7.0
- typo3/cms-core: ^6.2 || ^7.6 || ^8.7
- typo3/cms-frontend: ^6.2 || ^7.6 || ^8.7
Requires (Dev)
- jakub-onderka/php-console-highlighter: ^0.3.2
- jakub-onderka/php-parallel-lint: ^0.9.2
- nimut/testing-framework: ^1.1
- phpunit/phpunit: ^5.7
Replaces
- cors: 2.0.6
- typo3-ter/cors: 2.0.6
README
为TYPO3提供跨源资源共享。
安装
此扩展可以从各种来源安装
-
通过Composer
composer require pagemachine/cors
配置
所有配置选项都可以通过在 config.cors
或页面对象中的 page.config.cors
中的 TypoScript 设置来设置。以下选项可用:
选项 | 类型 | 描述 |
---|---|---|
allowCredentials |
int/boolean | 处理 credentials 标志 |
allowHeaders |
string | 允许的头部列表(X-Foo, ...),简单头部始终允许 |
allowMethods |
string | 允许的方法列表(PUT, DELETE, ...),简单方法始终允许 |
allowOrigin |
string | 允许的来源列表 |
allowOrigin.pattern |
string | 匹配来源的正则表达式,确保按需转义 |
exposeHeaders |
string | 暴露给客户端的头部列表 |
maxAge |
int | 预检请求的缓存生命周期,注意浏览器的限制 |
注意,所有选项都支持通过它们的 .stdWrap
属性进行 stdWrap 处理。
示例
-
来源通配符
config.cors { allowOrigin = * }
-
简单的来源列表
config.cors { allowOrigin = http://example.org, http://example.com // More readable version allowOrigin ( http://example.org, http://example.com ) }
-
通过正则表达式匹配来源
config.cors { allowOrigin.pattern = https?://example\.(org|com) }
-
允许特定方法
config.cors { allowMethods = GET, POST, PUT, DELETE }
-
允许头部
config.cors { allowHeaders = ( Content-Type, ... ) }
-
允许处理
credential
标志config.cors { // Set to 1/true to enable allowCredentials = 1 }
-
暴露头部
config.cors { exposeHeaders ( X-My-Custom-Header, X-Another-Custom-Header ) }
-
设置预检请求结果的最高年龄
config.cors { // 10 minutes maxAge = 600 }
-
通过某些
stdWrap
处理设置最高年龄config.cors { maxAge.stdWrap.cObject = TEXT maxAge.stdWrap.cObject { value = 600 } }
问题
发现了错误?需要功能?通过我们的 问题跟踪器告诉我们。
测试
可以使用随附的 Docker Compose 定义执行所有测试。
docker-compose run --rm app composer build