Skip to content

DOCXKIT_PREVIEW_FETCH_FAILED: 預覽檔案擷取失敗 ​

未能成功從 URL 擷取 DOCX 檔案。

修復步驟 ​

  1. 檢查 HTTP 回應、網路、身分驗證與 CORS 設定。
  2. 無法遠端擷取時傳入本機 DOCX 位元組。

問題範例 ​

ts
import { createDocx, createDocxPreview } from 'docx-kit'

const container = document.createElement('div')
document.body.append(container)

const preview = createDocxPreview(container)
try {
  await preview.render('https://example.com/missing.docx')
} finally { preview.destroy() }

修復範例 ​

ts
import { createDocx, createDocxPreview } from 'docx-kit'

const container = document.createElement('div')
document.body.append(container)

const preview = createDocxPreview(container)
try {
  const blob = await createDocx().p('Hello').toBlob()
  await preview.render(blob)
} finally { preview.destroy() }

常見原因 ​

  • HTTP 回應失敗、網路錯誤,或跨來源請求遭到阻擋。

診斷欄位 ​

訊息範例 ​

text
Failed to fetch DOCX: HTTP 404

原始碼與相關指南 ​

Released under the MIT License.