1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Firefoxアドオンでfetch APIを使うと "TypeError: NetworkError when attempting to fetch resource." になる

Posted at

概要

拡張機能のcontentscript上でfetchを使うと、chromeでは動作するのにfirefoxでは動作しない

原因

Firefoxのpermissionにて許可する必要がある。
manifest.jsonに拡張機能を動作させて良いURIパターンを追記する。
テストであれば以下の記述にすると、全ページで利用できるようになる。

  "permissions": [
    "*://*/*"
  ]

manifest.jsonに書く場合

manifest.json
{
  "name": "",
  "short_name": "",
  "description": "",
  "version": "0.0.0",
  "manifest_version": 2,
  "default_locale": "en",
   "icons": {
  },
  "background": {
  },
  "browser_action": {
  },
  "content_scripts": [
  ],
  "permissions": [
    "*://*/*"
  ]
}

試したこと

  • pollyfillを入れる
    • pollyfillでも同様のエラーが発生

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?