Restricting your Mapbox key to your website
When setting up a Mapbox key, it’s possible to restrict your key to only work with your website. This is optional, but can be a good idea – it ensures that no one else can copy your key from your website and use it on their own site.
Check your existing keys
If you’d like to create a key that only works with your website, you’ll need to create a separate key in the Mapbox dashboard.
Your keys will be listed on this page:
You'll always have a Default public token, and may also have one or more other keys listed there. The number listed after URLs in the key details indicates how many websites have been granted access. A 0 or N/A indicates the key is unrestricted, while a number of 1 or greater indicates that the key will only work on certain sites.
Set up a separate key
On the Access tokens page of the Mapbox dashboard, click Create a token to set up a new key:
Under Token scopes, leave the default option selected. All the checkboxes under Public scopes should be ticked, and all the checkboxes under Private scopes should not be ticked:
Set up URL restrictions
Caution: It's important to only list the plain domain for each entry (e.g. example.com). Adding the full URL to your page (e.g. www.example.com/pages/map) won't work in certain browsers.
Platform-specific URLs
Certain hosting platforms also need additional entries in the list:
For Shopify sites, you'll want to add:
- Your live domain(s), e.g. example.com
- Your myshopify.com domain, e.g. example.myshopify.com
- shopifypreview.com
For Wix sites, you'll want to add:
- Your live domain, e.g. example.com
- filesusr.com
For GoDaddy sites, you'll want to add:
- Your live domain, e.g. example.com
- about:srcdoc
Once your domain(s) have been added, click Create token or Save changes:
Finally, copy your new token from the Mapbox dashboard and paste it into Stockist under "Settings > Map provider":
Please be sure to paste the restricted token into Stockist. The Default public token isn't secured, and other people could copy it from your Stockist map to use on their own site.