Xử lý một preflight OPTIONS. Server có whitelist origin, danh sách method cho phép, danh sách header cho phép. Trình duyệt gửi Origin, Access-Control-Request-Method, Access-Control-Request-Headers (có thể rỗng).
Thứ tự kiểm tra (in cảnh báo đầu tiên gặp):
BLOCK origin.BLOCK method.BLOCK header <tên-đầu-tiên-bị-từ-chối> (dạng gốc đã trim).Access-Control-Allow-Origin: <origin>
Access-Control-Allow-Methods: <method-yêu-cầu>
Access-Control-Allow-Headers: <danh-sách-header-yêu-cầu nối bằng ', '>
Nếu không có header yêu cầu nào, dòng thứ 3 in Access-Control-Allow-Headers: -.
Input:
n whitelist; n dòng.Input:
1
https://a.com
GET,POST,PUT
Content-Type,Authorization
https://a.com
PUT
Content-Type
Output:
Access-Control-Allow-Origin: https://a.com
Access-Control-Allow-Methods: PUT
Access-Control-Allow-Headers: Content-Type
n+whitelist / methods / headers / origin / req-method / req-headers.
1 ≤ n ≤ 50.
BLOCK ... hoặc 3 dòng header.
Ví dụ:
Đầu vào:
1
https://a.com
GET,POST,PUT
Content-Type,Authorization
https://a.com
PUT
Content-Type
Đầu ra:
Access-Control-Allow-Origin: https://a.com
Access-Control-Allow-Methods: PUT
Access-Control-Allow-Headers: Content-Type
Giải thích:
Đang tải editor...