当前位置:网站首页>thinkphp5.1跨域问题解决
thinkphp5.1跨域问题解决
2022-07-05 22:17:00 【沐言鸭】
新建一个控制器–Cross
php think make:controller api/Cross
阅读官方文档tp5.1跨域可以了解到基本写法
在此控制器里面初始化方法
protected function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:GET, POST, PATCH, PUT, DELETE');
header('Access-Control-Allow-Headers:Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With');
if (request()->isOptions()){
exit();
}
}
即可解决问题
边栏推荐
- Promql demo service
- [Yugong series] go teaching course in July 2022 004 go code Notes
- Solutions for unexplained downtime of MySQL services
- Win11 runs CMD to prompt the solution of "the requested operation needs to be promoted"
- 航海日答题小程序之航海知识竞赛初赛
- Server optimization of performance tuning methodology
- Blocking of concurrency control
- Web3为互联网带来了哪些改变?
- The statistics of leetcode simple question is the public string that has appeared once
- Metaverse Ape获Negentropy Capital种子轮融资350万美元
猜你喜欢

Blocking of concurrency control

boundary IoU 的计算方式

ESP32 hosted

Installation of VMware Workstation

Business learning of mall order module

What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial

Sentinel production environment practice (I)

Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference
![[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)](/img/3e/34b45cd14f0302bb381efd244bc68f.jpg)
[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)
![[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)](/img/ab/086c7455706eecc467eef92c660803.jpg)
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
随机推荐
Leetcode simple question: find the nearest point with the same X or Y coordinate
MySQL disconnection reports an error MySQL ldb_ exceptions. OperationalError 4031, The client was disconnected by the server
119. Pascal‘s Triangle II. Sol
Did you brush the real title of the blue bridge cup over the years? Come here and teach you to counter attack!
Pinctrl subsystem and GPIO subsystem
Go语言学习教程(十五)
Official clarification statement of Jihu company
The real situation of programmers
Leetcode simple question: the minimum cost of buying candy at a discount
U盘的文件无法删除文件怎么办?Win11无法删除U盘文件解决教程
What changes has Web3 brought to the Internet?
Two stage locking protocol for concurrency control
Kubernetes Administrator certification (CKA) exam notes (IV)
Database recovery strategy
装饰器学习01
The statistics of leetcode simple question is the public string that has appeared once
A substring with a length of three and different characters in the leetcode simple question
Countdown to 92 days, the strategy for the provincial preparation of the Blue Bridge Cup is coming~
每日刷题记录 (十四)
The simple problem of leetcode is to split a string into several groups of length K