Serve Static Files from the Domain of an App User's Site

Note:
This functionality is currently in Alpha testing and is not currently available for all users. If you'd like to request access to this functionality, submit a proposal.

In addition, this feature requires the app to have an embedded script extension as well. Learn more
You can use your app to serve static files, which are hosted on your servers, via the domain of the installed site.
This functionality is useful when your script needs to communicate with a service worker (a script that your browser runs in the background) to enable offline experiences like push notifications and background sync.
Important:
You should serve your file from a Content Distribution Network (CDN). This will optimize loading times for users in various regions of the world.

Limitations

Embedded script apps can only be added by the owners of Wix sites with a Premium Plan as well as a connected domain.

Serve a static file with your app

In order to serve a static file, you need to:
  1. Create an app with a static file extension
  2. Use your static file with the embedded script extension

1. Create an app with a static file extension

  1. Create a new app, or log in to an existing app, in the Wix Developers Center.
  2. Go to Extension in the side menu (under Build Your App).
  3. Click + Add Website Extension.
  4. Select Static File and click Add Extension.
  5. Name your extension. Extension names may only contain letters and the hyphen (-) character (this is for internal usage only, and will not be visible to users using the app, but you will want to reference it in your file's code under "componentName", see example below.)
  6. Add the url of the file (hosted on your server) that you want to serve. 
1
2
3
4
{
  "url": "https://cdn.mydomain.com/script.js",
  "componentName": "myExtentionName"
}
Note:
Wix does not cache the file, so you have to keep it live and available on your side. The file must be served from a valid URL and over HTTPS.
7. Don't forget to Save the extension.

2. Use the static file with your embedded script

The embedded script extension enables your app to insert custom script tags into the <head> tag of your users' websites.

Make sure to add your static file with the following path: "app-resource-proxy/v1/resource/APP_ID/filename.js"

Learn more about embedded scripts.

Related Content