[轉貼]php API 跨域請求 – IT閱讀

處理PHP API 跨域請求:

設定API相應的http頭,讓該介面支援跨域請求

header(“Content-type: application/json”);
header(“Access-Control-Allow-Origin: *” );
header(“Access-Control-Allow-Methods: GET, OPTIONS, POST”);
header(“Access-Control-Allow-Credentials: true”);
header(“Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding, X-Requested-With, Origin”);

處理PHP API 跨域請求:設定API相應的http頭,讓該介面支援跨域請求   header(“Content-type: application/json”);   header(“Access-Control-Allow-Origin:  *” );    header(“Access-Control-Allow-Methods: GET, OPTIONS, POST”);    header(“Access-Control-Allow-Credentials: true”);    header(“Access-Control-Allow-Headers: Content-Type, Content-Length, Accept-Encoding, X-Requested-With, Origin”);

內容出處: php API 跨域請求 – IT閱讀

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *