Cách dùng: Bộ tạo CORS Header
Bộ tạo CORS Header là công cụ Công cụ web trực tuyến miễn phí, giúp generate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker ngay trong trình duyệt. Dán dữ liệu, chỉnh tùy chọn và nhận kết quả tức thì — không cài đặt, không đăng ký, không tải lên máy chủ.
Dùng Bộ tạo CORS Header ngay →
Mô tả
Generate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker.
- Công cụ web
- Vì mọi tính toán đều ở phía máy khách, Bộ tạo CORS Header an toàn với dữ liệu nhạy cảm như API key hay token.
Cách dùng
Dùng Bộ tạo CORS Header chỉ ba bước:
- Dán dữ liệu vào ô nhập (hoặc nạp ví dụ).
- Chỉnh tùy chọn theo định dạng mong muốn.
- Sao chép, tải hoặc xem kết quả — cập nhật khi bạn gõ.
Chạy
Ví dụ
List the allowed origins; a wildcard combined with credentials is rejected because browsers forbid it.
Đầu ra(由工具此刻实时生成)
# nginx — 1 explicit origin(s)
location /api/ {
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "https://app.example.com" always;
add_header Access-Control-Allow-Methods "GET,POST,PUT,PATCH,DELETE,OPTIONS" always;
add_header Access-Control-Allow-Headers "Content-Type,Authorization,X-Requested-With" always;
add_header Access-Control-Expose-Headers "Content-Length,X-Request-Id" always;
add_header Access-Control-Max-Age "86400" always;
add_header Content-Length 0;
add_header Content-Type text/plain;
return 204;
}
add_header Access-Control-Allow-Origin "https://app.example.com" always;
add_header Access-Control-Allow-Methods "GET,POST,PUT,PATCH,DELETE,OPTIONS" always;
add_header Access-Control-Allow-Headers "Content-Type,Authorization,X-Requested-With" always;
add_header Access-Control-Expose-Headers "Content-Length,X-Request-Id" always;
proxy_pass http://127.0.0.1:8720;
}
Notes
• Preflight is cached for 86400s, so browsers skip the OPTIONS round trip during that window.
• CORS protects browsers, not your server — it is not an authentication mechanism. Enforce authorisation server-side too.
此输出由工具真实运行产生,并非人工编写。
Tình huống sử dụng
Những tình huống phổ biến mà Bộ tạo CORS Header hữu ích:
- Generate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker.
Tham số
Công cụ này không có tùy chọn — chỉ tác động lên đầu vào.
FAQ
CORS Header Generator là gì?
CORS Header Generator dùng để generate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker. Chạy hoàn toàn trong trình duyệt nên dữ liệu của bạn được bảo mật.
CORS Header Generator có miễn phí không?
Có. Không giới hạn, không đăng ký, không cài đặt.
Dữ liệu của tôi có bị tải lên?
Không. Mọi xử lý diễn ra ngay trên máy bạn.
Cần lưu ý
- 全部计算在浏览器端完成,因此超大输入受限于标签页内存,而非服务器上传限制。