?????? ??? ?? ??? ??? ??? ??? ? ??? ?? ? ???? ?? ??? ?????. thinkphp ?????? ???? ??? ? ??? ? ?? ????? ???? ???? ???? ??? ?????? ? ????? ??? ? ??? ???? ?? thinkphp ?????? ?? ???? Header ??? ? ?? ?????? ???? ??? ?????.
1. ?? ???
thinkphp ???????? ?? ???? ???? ??? ? ?? ??? ???? ?? ??? ??? ? ????. ???? ??? ???? ???? ?? ??? ???? ????.
header("Access-Control-Allow-Origin:?*"); header("Access-Control-Allow-Headers:?Origin,?X-Requested-With,?Content-Type,?Accept");
? ? ? ?? ?? ?? ?? ??? ??? ? ??? ???? ???? ? ???? ?? ?? ??? ??? ?? ????. ??? ?? ??? ??? ?? ???? ??? ???? ?????. ?? ??? ??? ???? ?? ??? ??? ??? ? ????.
2. ?? ?????
Header ???? ???? ??? ? ??? ???? ? ??? ?? ?????? ???? ? ????? ???? ?? ????. ??? ?? CORS(Cross-Origin Resource Sharing) ????? cors ??? ?? ?? ?? ?????? ???? ??? ? ??? ???? ??? ?????.
- cors ?? ??
??? ?? ?? ?? ??? ?????.
composer?require?topthink/think-cors
- cors ?? ??
????? config ???? cors.php ??? ??? ?? ??? ?????.
<?php return [ // 允許的請(qǐng)求域名 'allow_origin' =>?['*'], ????//?允許的請(qǐng)求頭信息 ????'allow_headers'?????=>?'Origin,?X-Requested-With,?Content-Type,?Accept', ????//?允許的請(qǐng)求方法 ????'allow_methods'?????=>?'GET,?POST,?PUT,?DELETE,?PATCH', ????//?是否允許發(fā)送cookie ????'allow_credentials'?=>?true, ????//?跨域請(qǐng)求緩存時(shí)間 ????'max_age'???????????=>?3600, ];
? ? $allow_origin? ??? ?? ??? ??? ????, ?? ?? ??? ???? ????? ????? ?? "*"? ??? ? ????. $allow_headers? ???? ?? ?? ??? ????, $allow_methods? ???? ?? ??? ?????. $allow_credentials? ?? ??? ????? ??? ????, $max_age? ??? ? ?? ?? ??? ?????.
- ?? ?? ??
????? config ???? app.php ??? ??? ??? ??? ????.
return?[ ????//?... ????'middleware'?=>?[ ????????//?... ????????\think\middleware\Cors::class, ????], ];
- Call cors ??
??? ???? ??? ???? ????? ??? ?? ??? ? ????. ??? ? ?? ??? ???? cors ??? ???:
use?think\facade\Cors; public?function?index()?{ ????Cors::allowAllOrigin(); ????return?json(['code'?=>?200,?'msg'?=>?'success']); }
?? ???? ??? ? ??? ? ??? ??? ? ????.
?????, thinkphp ?????? ??? ? ?? ????? ???? ???? ????? Header ???? ?? ?????? ??? ? ????. Header ???? ???? ?? ?? ??? ???? ???? ?? ?????? ???? ?? ????? ??????. ???? ?? ??? ??? ??? ?? ??? ? ????.
? ??? thinkphp?? ??? ? ??? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)