多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 跨域请求 如果某个路由或者分组需要支持跨域请求,可以使用 ~~~ Route::get('new/:id', 'News/read') ->ext('html') ->allowCrossDomain(); ~~~ >[danger] 跨域请求一般会发送一条`OPTIONS`的请求,一旦设置了跨域请求的话,不需要自己定义`OPTIONS`请求的路由,系统会自动加上。 > 跨域请求系统会默认带上一些Header,包括: ~~~ Access-Control-Allow-Origin:* Access-Control-Allow-Methods:GET, POST, PATCH, PUT, DELETE Access-Control-Allow-Headers:Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With ~~~ 你可以添加或者更改Header信息,使用 ~~~ Route::get('new/:id', 'News/read') ->ext('html') ->header('Access-Control-Allow-Origin','thinkphp.cn') ->header('Access-Control-Allow-Credentials', 'true') ->allowCrossDomain(); ~~~