# Cannot acces a web-accessible-resource through "moz-extension://\<extension-id\>/\<path/to/resource\>"

**URL:** <https://discourse.mozilla.org/t/cannot-acces-a-web-accessible-resource-through-moz-extension-extension-id-path-to-resource/10046>\
**Category:** Add-on Support\
**Created:** [August 2, 2016, 12:17pm UTC](https://discourse.mozilla.org/t/cannot-acces-a-web-accessible-resource-through-moz-extension-extension-id-path-to-resource/10046 "2016-08-02T12:17:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![meron.brouwer](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@meron.brouwer](https://discourse.mozilla.org/u/meron.brouwer)\
**Post date:** [August 2, 2016, 12:17pm UTC](https://discourse.mozilla.org/t/cannot-acces-a-web-accessible-resource-through-moz-extension-extension-id-path-to-resource/10046/1 "2016-08-02T12:17:14Z")

</div>

I am trying to detect if an extension is installed by accessing a web-accessible-resource as described here:

[https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/web\_accessible\_resources](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/web_accessible_resources)

The id listed in the manifest is [foo@bar.com](mailto:foo@bar.com) and the accessible file is correctly listed in the manifest (and named copyright.txt)

So i would expect that can can access this file through

moz-extension://foo@bar.com/copyright.txt

but this leads to nothing.

The complete analogue situation, with a Chrome Extension, does return the copyright.txt.

There is very little documentation on this. What am I doing wrong or missing here?

Cheers,  
Meron

---

<div class="post-metadata">

**Author:** ![desktopd](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/desktopd/32/4520_2.png) [@desktopd](https://discourse.mozilla.org/u/desktopd)\
**Post date:** [August 5, 2016, 5:49am UTC](https://discourse.mozilla.org/t/cannot-acces-a-web-accessible-resource-through-moz-extension-extension-id-path-to-resource/10046/2 "2016-08-05T05:49:40Z")

</div>

The id is different for each installation:  
[https://discourse.mozilla-community.org/t/constant-or-well-known-mox-extension-uuid-for-webextension/9701?u=desktopd](https://discourse.mozilla-community.org/t/constant-or-well-known-mox-extension-uuid-for-webextension/9701?u=desktopd)

* * *

So you need to use this…

> **[extension.getURL()](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/Extension/getURL)**
>
> Converts a relative path within an extension's install directory to a fully-qualified URL.

---

<div class="post-metadata">

**Author:** ![keen](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/keen/32/5794_2.png) [@keen](https://discourse.mozilla.org/u/keen)\
**Post date:** [September 19, 2016, 9:04am UTC](https://discourse.mozilla.org/t/cannot-acces-a-web-accessible-resource-through-moz-extension-extension-id-path-to-resource/10046/3 "2016-09-19T09:04:44Z")

</div>

We have the same issue - the problem with extension.getURL() is that it can only run from the extension itself, meaning that we’ll need to ‘communicate’ the extension URL to the web page somehow (i.e. inject an invisible div).

Since we use the web\_accessible\_resources just to detect prior installation of our extensions, then we might as well give up completely on web\_accessible\_resources and just inject an invisible div which will indicate to our webpage that the extension has been previously installed.

Is there any possible better way to detect previous extension installs? Perhaps we need to somehow specify a permanent extension ID?
