วิธีใช้: ตัวสร้าง CORS Header

ตัวสร้าง CORS Header คือเครื่องมือ เครื่องมือเว็บ ออนไลน์ฟรีที่ generate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker ทันทีในเบราว์เซอร์ของคุณ วางข้อมูล ปรับตัวเลือก แล้วได้ผลแบบเรียลไทม์ — ไม่ต้องติดตั้ง ไม่ต้องสมัคร และไม่มีการอัปโหลดข้อมูล

ใช้ ตัวสร้าง CORS Header ทันที →

คำอธิบาย

Generate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker.

  • เครื่องมือเว็บ
  • ด้วยการคำนวณฝั่งไคลเอ็นต์ทั้งหมด ตัวสร้าง CORS Header จึงปลอดภัยสำหรับข้อมูลที่ละเอียดอ่อน เช่น API key
ข้อมูลเข้า ตัวสร้าง CORS Header ข้อมูลออก ทำงาน 100% ในเบราว์เซอร์ของคุณ — ข้อมูลไม่ออกจากอุปกรณ์
ตัวสร้าง CORS Header — ข้อมูลเข้า → ข้อมูลออก

วิธีใช้

ใช้ ตัวสร้าง CORS Header ในสามขั้นตอน:

  1. วางข้อมูลในช่องอินพุต (หรือโหลดตัวอย่าง)
  2. ปรับตัวเลือกให้ตรงกับรูปแบบที่ต้องการ
  3. คัดลอก ดาวน์โหลด หรือตรวจสอบเอาต์พุต — อัปเดตทันทีขณะพิมพ์
วิธีใช้ · ตัวสร้าง CORS Header 1 วางข้อมูลในช่องอินพุต(หรือโหลดตัวอย่าง) 2 ปรับตัวเลือกให้ตรงกับรูปแบบที่… 3 คัดลอก ดาวน์โหลดหรือตรวจสอบเอาต์พุต —อัปเดตทันทีขณะพิมพ์
วิธีใช้

รัน

ตัวอย่าง

List the allowed origins; a wildcard combined with credentials is rejected because browsers forbid it.

ข้อมูลออก(由工具此刻实时生成)

# 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.

此输出由工具真实运行产生,并非人工编写。

กรณีใช้งาน

สถานการณ์ทั่วไปที่ ตัวสร้าง CORS Header ช่วยได้:

  • Generate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker.

พารามิเตอร์

เครื่องมือนี้ไม่มีตัวเลือก ทำงานกับอินพุตโดยตรง

คำถามที่พบบ่อย

CORS Header Generator คืออะไร?

CORS Header Generator ใช้เพื่อgenerate correct CORS headers and preflight handling for nginx, Express, Apache, PHP or a Cloudflare Worker ทำงานทั้งหมดในเบราว์เซอร์ ข้อมูลของคุณเป็นส่วนตัว

CORS Header Generator ใช้ง่ายฟรีไหม?

ฟรี ไม่จำกัด ไม่ต้องสมัครหรือติดตั้ง

ข้อมูลของฉันถูกอัปโหลดไหม?

ไม่ ทุกอย่างประมวลผลในเครื่องของคุณ

ข้อควรรู้

  • 全部计算在浏览器端完成,因此超大输入受限于标签页内存,而非服务器上传限制。

เครื่องมือที่เกี่ยวข้อง

ตัวสร้าง CORS Header → · เครื่องมือเว็บ →

ใช้ ตัวสร้าง CORS Header ทันที →