• 跳至主要內容
  • 跳至搜尋
  • 跳至選擇語言
MDN Web Docs - MDN 文件
  • 參考資料
    • 概述 / Web 技術

      面向開發人員的 Web 技術參考

    • HTML

      網頁內容結構

    • CSS

      用於描述文件樣式的程式碼

    • JavaScript

      通用指令碼語言

    • HTTP

      用於傳輸 Web 資源的協議

    • Web API

      用於構建 Web 應用程式的介面

    • Web 擴充套件

      開發 Web 瀏覽器擴充套件

    • Web 技術

      面向開發人員的 Web 技術參考

  • 指南
    • 概述 / MDN 學習區域

      學習 Web 開發

    • MDN 學習區域

      學習 Web 開發

    • HTML

      學習使用 HTML 結構化 Web 內容

    • CSS

      學習使用 CSS 樣式化內容

    • JavaScript

      學習在瀏覽器中執行指令碼

    • 無障礙性

      學習如何使 Web 對所有人無障礙

  • 此外
    • 概述

      定製的 MDN 體驗

    • AI 幫助

      獲得即時幫助和支援

    • 更新

      所有瀏覽器相容性更新一覽

    • 文件

      瞭解如何使用 MDN Plus

    • 常見問題解答

      關於 MDN Plus 的常見問題解答

  • 課程
  • 部落格
    • 遊樂場

      編寫、測試和分享您的程式碼

    • 新
      HTTP 觀測站

      免費掃描網站

    • AI 幫助

      獲得即時幫助和支援

  • 登入
  • 免費註冊
  1. 參考資料
  2. HTTP
  3. 跨域資源共享 (CORS)
  4. CORS 錯誤
  5. 原因:CORS 標頭“Origin”無法新增
    • 日語
    • 韓語
    • 中文(簡體)

本文內容

  • 原因
  • 出了什麼問題?
  • 另請參閱
  1. HTTP
  2. 指南
  3. 資源和 URI
    1. 識別 Web 上的資源
    2. 資料 URL
    3. MIME 型別簡介
    4. 常見 MIME 型別
    5. 在 www 和非 www URL 之間選擇
  4. HTTP 指南
    1. HTTP 基礎知識
    2. HTTP 概述
    3. HTTP 的演變
    4. HTTP 訊息
    5. 典型的 HTTP 會話
    6. HTTP/1.x 中的連線管理
    7. 協議升級機制
  5. HTTP 安全
    1. 內容安全策略 (CSP)
    2. HTTP 嚴格傳輸安全 (HSTS)
    3. X-Content-Type-Options
    4. X-Frame-Options
    5. X-XSS-Protection
    6. 實用的安全實施指南
    7. HTTP 觀測站
  6. HTTP 訪問控制 (CORS)
  7. HTTP 身份驗證
  8. HTTP 快取
  9. HTTP 壓縮
  10. HTTP 條件請求
  11. HTTP 內容協商
  12. HTTP Cookie
  13. HTTP 範圍請求
  14. HTTP 重定向
  15. HTTP 規範
  16. 許可權策略
  17. 參考資料
  18. HTTP 標頭
    1. 接受
    2. Accept-CH
    3. Accept-Charset
    4. Accept-Encoding
    5. Accept-Language
    6. Accept-Patch
    7. Accept-Post
    8. Accept-Ranges
    9. Access-Control-Allow-Credentials
    10. Access-Control-Allow-Headers
    11. Access-Control-Allow-Methods
    12. Access-Control-Allow-Origin
    13. Access-Control-Expose-Headers
    14. Access-Control-Max-Age
    15. Access-Control-Request-Headers
    16. Access-Control-Request-Method
    17. 年齡
    18. 允許
    19. Alt-Svc
    20. Alt-Used
    21. Attribution-Reporting-Eligible 實驗性
    22. Attribution-Reporting-Register-Source 實驗性
    23. Attribution-Reporting-Register-Trigger 實驗性
    24. 授權
    25. Cache-Control
    26. Clear-Site-Data
    27. 連線
    28. Content-Digest 實驗性
    29. Content-Disposition
    30. Content-DPR 非標準 已棄用
    31. Content-Encoding
    32. Content-Language
    33. Content-Length
    34. Content-Location
    35. Content-Range
    36. Content-Security-Policy
    37. Content-Security-Policy-Report-Only
    38. Content-Type
    39. Cookie
    40. Critical-CH 實驗性
    41. Cross-Origin-Embedder-Policy
    42. Cross-Origin-Opener-Policy
    43. Cross-Origin-Resource-Policy
    44. 日期
    45. Device-Memory
    46. Digest 非標準 已棄用
    47. DNT 非標準 已棄用
    48. Downlink 實驗性
    49. DPR 非標準 已棄用
    50. Early-Data 實驗性
    51. ECT 實驗性
    52. ETag
    53. 預期
    54. Expect-CT
    55. 過期
    56. 轉發
    57. 來自
    58. 主機
    59. If-Match
    60. If-Modified-Since
    61. If-None-Match
    62. If-Range
    63. If-Unmodified-Since
    64. 保持活動
    65. 上次修改
    66. 連結
    67. 位置
    68. Max-Forwards
    69. NEL 實驗性
    70. No-Vary-Search 實驗性
    71. Observe-Browsing-Topics 實驗性 非標準
    72. Origin
    73. Origin-Agent-Cluster 實驗性
    74. Permissions-Policy
    75. Pragma 已棄用
    76. 優先順序
    77. Proxy-Authenticate
    78. Proxy-Authorization
    79. 範圍
    80. 引用者
    81. Referrer-Policy
    82. Report-To 非標準 已棄用
    83. Reporting-Endpoints 實驗性
    84. Repr-Digest 實驗性
    85. 重試-之後
    86. RTT 實驗性
    87. Save-Data 實驗性
    88. Sec-Browsing-Topics 實驗性 非標準
    89. Sec-CH-Prefers-Color-Scheme 實驗性
    90. Sec-CH-Prefers-Reduced-Motion 實驗性
    91. Sec-CH-Prefers-Reduced-Transparency 實驗性
    92. Sec-CH-UA 實驗性
    93. Sec-CH-UA-Arch 實驗性
    94. Sec-CH-UA-Bitness 實驗性
    95. Sec-CH-UA-Full-Version 已棄用
    96. Sec-CH-UA-Full-Version-List 實驗性
    97. Sec-CH-UA-Mobile 實驗性
    98. Sec-CH-UA-Model 實驗性
    99. Sec-CH-UA-Platform 實驗性
    100. Sec-CH-UA-Platform-Version 實驗性
    101. Sec-Fetch-Dest
    102. Sec-Fetch-Mode
    103. Sec-Fetch-Site
    104. Sec-Fetch-User
    105. Sec-GPC 實驗性 非標準
    106. Sec-Purpose
    107. Sec-WebSocket-Accept
    108. Sec-WebSocket-Key
    109. Server
    110. Server-Timing
    111. Service-Worker-Navigation-Preload
    112. Set-Cookie
    113. Set-Login 實驗性
    114. SourceMap
    115. Speculation-Rules 實驗性
    116. Strict-Transport-Security
    117. Supports-Loading-Mode 實驗性
    118. TE
    119. Timing-Allow-Origin
    120. Tk 非標準 已棄用
    121. Trailer
    122. Transfer-Encoding
    123. Upgrade
    124. Upgrade-Insecure-Requests
    125. User-Agent
    126. Vary
    127. Via
    128. Viewport-Width 非標準 已棄用
    129. Want-Content-Digest 實驗性
    130. Want-Digest 非標準 已棄用
    131. Want-Repr-Digest 實驗性
    132. Warning 已棄用
    133. Width 非標準 已棄用
    134. WWW-Authenticate
    135. X-Content-Type-Options
    136. X-DNS-Prefetch-Control 非標準
    137. X-Forwarded-For 非標準
    138. X-Forwarded-Host 非標準
    139. X-Forwarded-Proto 非標準
    140. X-Frame-Options
    141. X-XSS-Protection 非標準
  19. HTTP 請求方法
    1. CONNECT
    2. DELETE
    3. GET
    4. HEAD
    5. OPTIONS
    6. PATCH
    7. POST
    8. PUT
    9. TRACE
  20. HTTP 響應狀態碼
    1. 100 Continue
    2. 101 Switching Protocols
    3. 102 Processing
    4. 103 Early Hints
    5. 200 OK
    6. 201 Created
    7. 202 Accepted
    8. 203 Non-Authoritative Information
    9. 204 No Content
    10. 205 Reset Content
    11. 206 Partial Content
    12. 207 Multi-Status
    13. 208 Already Reported
    14. 226 IM Used
    15. 300 Multiple Choices
    16. 301 Moved Permanently
    17. 302 Found
    18. 303 See Other
    19. 304 Not Modified
    20. 307 Temporary Redirect
    21. 308 Permanent Redirect
    22. 400 Bad Request
    23. 401 Unauthorized
    24. 402 Payment Required
    25. 403 Forbidden
    26. 404 Not Found
    27. 405 Method Not Allowed
    28. 406 Not Acceptable
    29. 407 Proxy Authentication Required
    30. 408 Request Timeout
    31. 409 Conflict
    32. 410 Gone
    33. 411 Length Required
    34. 412 Precondition Failed
    35. 413 Content Too Large
    36. 414 URI Too Long
    37. 415 Unsupported Media Type
    38. 416 Range Not Satisfiable
    39. 417 Expectation Failed
    40. 418 I'm a teapot
    41. 421 Misdirected Request
    42. 422 Unprocessable Content
    43. 423 Locked
    44. 424 Failed Dependency
    45. 425 Too Early
    46. 426 Upgrade Required
    47. 428 Precondition Required
    48. 429 Too Many Requests
    49. 431 Request Header Fields Too Large
    50. 451 Unavailable For Legal Reasons
    51. 500 Internal Server Error
    52. 501 Not Implemented
    53. 502 Bad Gateway
    54. 503 Service Unavailable
    55. 504 Gateway Timeout
    56. 505 HTTP Version Not Supported
    57. 506 Variant Also Negotiates
    58. 507 Insufficient Storage
    59. 508 Loop Detected
    60. 510 Not Extended
    61. 511 Network Authentication Required
  21. CSP 指令
    1. CSP 源值
    2. CSP: base-uri
    3. CSP: block-all-mixed-content 已棄用
    4. CSP: child-src
    5. CSP: connect-src
    6. CSP: default-src
    7. CSP: fenced-frame-src 實驗性
    8. CSP: font-src
    9. CSP: form-action
    10. CSP: frame-ancestors
    11. CSP: frame-src
    12. CSP: img-src
    13. CSP: manifest-src
    14. CSP: media-src
    15. CSP: object-src
    16. CSP: prefetch-src 非標準 已棄用
    17. CSP: report-to
    18. CSP: report-uri 已棄用
    19. CSP: require-trusted-types-for 實驗性
    20. CSP: sandbox
    21. CSP: script-src
    22. CSP: script-src-attr
    23. CSP: script-src-elem
    24. CSP: style-src
    25. CSP: style-src-attr
    26. CSP: style-src-elem
    27. CSP: trusted-types 實驗性
    28. CSP: upgrade-insecure-requests
    29. CSP: worker-src
  22. CORS 錯誤
    1. 原因: CORS 已停用
    2. 原因: CORS 標頭 'Access-Control-Allow-Origin' 與 'xyz' 不匹配
    3. 原因: 缺少 CORS 標頭 'Access-Control-Allow-Origin'
    4. 原因:CORS 標頭“Origin”無法新增
    5. 原因: CORS 預檢通道未成功
    6. 原因: CORS 請求未成功
    7. 原因: 不允許 CORS 請求外部重定向
    8. 原因: CORS 請求不是 HTTP
    9. 原因: 如果 CORS 標頭 'Access-Control-Allow-Origin' 為 '*',則不支援憑據
    10. 原因: 在 CORS 標頭 'Access-Control-Allow-Methods' 中未找到方法
    11. 原因: 在 CORS 標頭 'Access-Control-Allow-Credentials' 中預期為 'true'
    12. 原因: CORS 標頭 'Access-Control-Allow-Headers' 中的無效令牌 'xyz'
    13. 原因: CORS 標頭 'Access-Control-Allow-Methods' 中的無效令牌 'xyz'
    14. 原因: CORS 預檢通道中缺少 CORS 標頭 'Access-Control-Allow-Headers' 中的令牌 'xyz'
    15. 原因: 不允許使用多個 CORS 標頭 'Access-Control-Allow-Origin'
  23. Permissions-Policy 指令
    1. Permissions-Policy: accelerometer 實驗性
    2. Permissions-Policy: ambient-light-sensor 實驗性
    3. Permissions-Policy: attribution-reporting 實驗性
    4. Permissions-Policy: autoplay 實驗性
    5. Permissions-Policy: bluetooth 實驗性
    6. Permissions-Policy: browsing-topics 實驗性 非標準
    7. Permissions-Policy: camera
    8. Permissions-Policy: compute-pressure 實驗性
    9. Permissions-Policy: display-capture
    10. Permissions-Policy: document-domain 實驗性
    11. Permissions-Policy: encrypted-media 實驗性
    12. Permissions-Policy: fullscreen
    13. Permissions-Policy: gamepad 實驗性
    14. Permissions-Policy: geolocation
    15. Permissions-Policy: gyroscope 實驗性
    16. Permissions-Policy: hid 實驗性
    17. Permissions-Policy: identity-credentials-get 實驗性
    18. Permissions-Policy: idle-detection Experimental
    19. Permissions-Policy: local-fonts Experimental
    20. Permissions-Policy: magnetometer Experimental
    21. Permissions-Policy: microphone
    22. Permissions-Policy: midi Experimental
    23. Permissions-Policy: otp-credentials Experimental
    24. Permissions-Policy: payment Experimental
    25. Permissions-Policy: picture-in-picture Experimental
    26. Permissions-Policy: publickey-credentials-create Experimental
    27. Permissions-Policy: publickey-credentials-get
    28. Permissions-Policy: screen-wake-lock
    29. Permissions-Policy: serial Experimental
    30. Permissions-Policy: speaker-selection Experimental
    31. Permissions-Policy: storage-access Experimental
    32. Permissions-Policy: usb Experimental
    33. Permissions-Policy: web-share
    34. Permissions-Policy: window-management Experimental
    35. Permissions-Policy: xr-spatial-tracking Experimental

本文內容

  • 原因
  • 出了什麼問題?
  • 另請參閱

原因:CORS 標頭“Origin”無法新增

原因

Reason: CORS header 'Origin' cannot be added

出了什麼問題?

The user agent was unable to add the required Origin header to the HTTP request. All CORS requests must have an Origin header.

This can happen if the JavaScript code is running with enhanced privileges allowing it access to multiple domains' content, for example.

另請參閱

  • CORS 錯誤
  • Glossary: CORS
  • CORS introduction

Help improve MDN

Learn how to contribute.

This page was last modified on Apr 10, 2023 by MDN contributors.

View this page on GitHub • Report a problem with this content
MDN logo - MDN 文件

Your blueprint for a better internet.

  • MDN on Mastodon
  • MDN on X (formerly Twitter)
  • MDN on GitHub
  • MDN Blog RSS Feed

MDN

  • About
  • 部落格
  • Careers
  • Advertise with us

Support

  • Product help
  • Report an issue

Our communities

  • MDN Community
  • MDN Forum
  • MDN Chat

Developers

  • Web Technologies
  • Learn Web Development
  • MDN Plus
  • Hacks Blog
Mozilla logo - MDN 文件
  • Website Privacy Notice
  • Cookies
  • Legal
  • Community Participation Guidelines

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2024by individual mozilla.org contributors. Content available under a Creative Commons license.

© . Content available under a Creative Commons license.