> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fingerprint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate Fastly Compute proxy integration to JavaScript agent v4

This guide covers upgrading the Fastly Compute proxy integration from `v0.3` to `v0.4`. The new version adds support for [JavaScript agent v4](/reference/migrating-from-v3-to-v4) while maintaining compatibility with v3, and also includes the following breaking changes:

* **Single backend**: The integration now uses one backend named `fingerprint` instead of region-specific backend names (`api.fpjs.io`, `eu.api.fpjs.io`, `ap.api.fpjs.io`). The `fpcdn.io` (CDN) backend has also been removed. Agent script downloads now go through the same `fingerprint` backend.
* **Plugin system removed**: Open Client Response plugins, sealed result decryption, and KV store saving are no longer supported.
* **Path variables now optional**: `AGENT_SCRIPT_DOWNLOAD_PATH` and `GET_RESULT_PATH` are only needed for backward compatibility with JavaScript agent v3.

## Migration overview

1. Upgrade the proxy integration to v0.4. Choose the migration path that matches how you deployed your integration: [using Terraform](#migrate-using-terraform) or [manually](#migrate-manually).
2. [Switch to JavaScript agent v4](#switch-to-javascript-agent-v4).
3. [Remove the plugin configuration resources](#removing-plugin-configuration-resources-optional) (if you were using them).

## Migrate using Terraform

### Step 1: Add the `region` variable

Add the `region` variable to your module configuration. Set it to the [region](/docs/regions) of your Fingerprint workspace:

```terraform theme={"theme":"github-dark-dimmed"}
module "fingerprint_fastly_compute_integration" {
  source             = "fingerprintjs/compute-fingerprint-proxy-integration/fastly"
  fastly_api_token   = "FASTLY_API_TOKEN"
  integration_domain = "metrics.yourwebsite.com"
  service_id         = "FASTLY_COMPUTE_SERVICE_ID"
  region             = "us" # or "eu" or "ap" // [!code ++]
  # agent_script_download_path and get_result_path are only needed for JS agent v3
}
```

You can also remove `kv_store_enabled = true` if you had it set, see [Removing plugin configuration resources](#removing-plugin-configuration-resources-optional) for more details.

### Step 2: Apply the Terraform changes

```shell theme={"theme":"github-dark-dimmed"}
terraform apply
```

Terraform automatically replaces the old region-specific backends and the `fpcdn.io` backend with a single `fingerprint` backend. If you had `kv_store_enabled = true`, the KV Store is also destroyed.

## Migrate manually

### Step 1: Update the proxy package

1. Go to the [latest release](https://github.com/fingerprintjs/fastly-compute-proxy/releases/latest) in the Fastly Compute Proxy Integration GitHub repository and download `fingerprint-fastly-compute-proxy-integration.tar.gz`.
2. In Fastly, open your proxy integration Compute service and go to **Package**.
3. Upload the new package and click **Activate**.

### Step 2: Replace the service backends

Replace all existing backends with a single backend named `fingerprint`:

1. In Fastly, open your proxy integration Compute service and go to **Origins**.
2. Add a new backend:
   * Set the **Name** to `fingerprint`. The proxy integration expects this exact name.
   * Set the **Address** and **Override host** to the Fingerprint API host for your workspace region:
     * `api.fpjs.io` — Global (US)
     * `eu.api.fpjs.io` — EU
     * `ap.api.fpjs.io` — Asia
3. Delete the old region-specific backends (`api.fpjs.io`, `eu.api.fpjs.io`, `ap.api.fpjs.io`) and the CDN backend (`fpcdn.io`).
4. Click **Activate** to deploy the changes.

## Switch to JavaScript agent v4

With the proxy upgraded, update your JavaScript agent to v4. See [Migrating from JavaScript agent v3 to v4](/reference/migrating-from-v3-to-v4) for more details.

<CodeGroup>
  ```javascript NPM package theme={"theme":"github-dark-dimmed"}
  import * as FingerprintJS from '@fingerprintjs/fingerprintjs-pro' // [!code --]
  import * as Fingerprint from '@fingerprint/agent' // [!code ++]

  const fpPromise = FingerprintJS.load({ // [!code --]
  const fp = Fingerprint.start({ // [!code ++]
    apiKey: 'PUBLIC_API_KEY',
    scriptUrlPattern: [ // [!code --:4]
      'https://metrics.yourwebsite.com/AGENT_SCRIPT_DOWNLOAD_PATH?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>',
      FingerprintJS.defaultScriptUrlPattern,
    ],
    endpoint: [ // [!code --:4]
      'https://metrics.yourwebsite.com/GET_RESULT_PATH?region=us',
      FingerprintJS.defaultEndpoint,
    ],
    endpoints: 'https://metrics.yourwebsite.com/', // [!code ++]
    region: 'us', // [!code ++]
  })
  ```

  ```javascript CDN theme={"theme":"github-dark-dimmed"}
  const fpPromise = import( // [!code --]
  const fp = import( // [!code ++]
    'https://metrics.yourwebsite.com/AGENT_SCRIPT_DOWNLOAD_PATH?apiKey=PUBLIC_API_KEY' // [!code --]
    'https://metrics.yourwebsite.com/web/v4/PUBLIC_API_KEY' // [!code ++]
  ).then((FingerprintJS) => FingerprintJS.load({ // [!code --]
  ).then((Fingerprint) => Fingerprint.start({ // [!code ++]
    endpoint: [ // [!code --:4]
      'https://metrics.yourwebsite.com/GET_RESULT_PATH?region=us',
      FingerprintJS.defaultEndpoint,
    ],
    apiKey: 'PUBLIC_API_KEY',
    endpoints: 'https://metrics.yourwebsite.com/', // [!code ++]
    region: 'us', // [!code ++]
  }))
  ```
</CodeGroup>

> Note: The `?region=us` query parameter inside the `endpoints` URL is no longer needed.

Once all your clients are on v4, you can also remove `AGENT_SCRIPT_DOWNLOAD_PATH` and `GET_RESULT_PATH` from your Config Store and Terraform configuration. They are only needed for JavaScript agent v3 support.

## Removing plugin configuration resources (optional)

If you were using the [Open Client Response plugins](/docs/v3/using-open-client-response-with-fastly-compute-proxy-integration-plugins), remove the following resources from your Fastly service.

### Remove plugin configuration from your Secret Store

1. In Fastly, go to **Resources** > [**Secret stores**](https://manage.fastly.com/resources/secret-stores).
2. Open `Fingerprint_Compute_Secret_Store_<SERVICE_ID>`.
3. Delete the `DECRYPTION_KEY` item.

> Note: Terraform does not manage Secret Store items. Remove `DECRYPTION_KEY` manually if you had it set.

### Remove plugin configuration from your Config Store

1. In Fastly, go to **Resources** > [**Config stores**](https://manage.fastly.com/resources/config-stores).
2. Open `Fingerprint_Compute_Config_Store_<SERVICE_ID>`.
3. Delete `OPEN_CLIENT_RESPONSE_PLUGINS_ENABLED` and `SAVE_TO_KV_STORE_PLUGIN_ENABLED` if they exist.

### Remove the KV Store

If you had the KV Store plugin enabled, remove the associated KV Store resource.

#### Manually

1. In Fastly, go to **Resources** > [**KV Stores**](https://manage.fastly.com/resources/kv-stores).
2. Find `Fingerprint_Results_<SERVICE_ID>`, unlink it from your service, and delete it.

#### Using Terraform

1. In Terraform, remove the `kv_store_enabled` variable from your module configuration.
2. Run `terraform apply` to remove the KV Store resource.
