# Allowed Connect domains

Pluggy Connect is the widget your users see when they link an account. It runs inside your site or
app, and anyone who holds a valid Connect Token for your application can try to load it somewhere
else: on their own page, branded as you, collecting the `onSuccess` result of your users' connections.

**Allowed Connect domains** lets you say where Connect may run. You list the websites (origins)
allowed to embed the widget, and Connect refuses to start for that application on any other site.

The restriction is optional and off by default. An application without it keeps working exactly as
before.

<Video
  src="/docs/videos/connect-allowed-domains/connect-allowed-domains-pt.mp4"
  poster="/docs/videos/connect-allowed-domains/connect-allowed-domains-pt-poster.jpg"
  captions="/docs/videos/connect-allowed-domains/connect-allowed-domains-pt.vtt"
  title="Setting up Allowed Connect domains in the Dashboard"
>
  A 33-second tour of Allowed Connect domains in the Dashboard. The on-screen text is in Portuguese.
</Video>

## How it works

When Connect starts, it works out which page is embedding it and asks Pluggy whether that page is
allowed for the application. If the application is restricted and the page is not on the list,
Connect shows a blocked screen and does not render the connection form.

Each application has one policy, with three parts:

- **Restrict where Connect can be used**: the on/off switch. When it is off, nothing is checked.
- **The list of allowed origins**: the websites and hybrid apps that may embed Connect.
- **Allow use outside a website**: whether Connect may run when it is not inside a web page, such
  as in a mobile app's web view or SDK, in a new tab, after a redirect or from a direct link.

## The three setups

| Setup | Allowed origins | Allow use outside a website |
| --- | --- | --- |
| Web and mobile | Your websites | On |
| Web only | Your websites | Off |
| Mobile only | Empty list | On |

- **Web and mobile.** Your websites can embed Connect, and so can your mobile apps. Pluggy's mobile
  SDKs load Connect outside a website, which is what **Allow use outside a website** covers.
- **Web only.** Only the listed websites can run Connect. A direct link, a new tab or a mobile web
  view is blocked.
- **Mobile only.** No website may embed Connect, but mobile apps keep working. Leave the list empty
  and keep **Allow use outside a website** on.

A policy that is restricted, has an empty list and has **Allow use outside a website** off would
block every load, so it cannot be saved.

## Set it up

Only a team's `OWNER`s and `ADMIN`s can edit the policy. `MEMBER`s see it read-only (see
[Team access](/docs/security/team-access)).

1. Open the [Dashboard](https://dashboard.pluggy.ai), go to **Applications** and open the
   application.
2. Find the **Domínios permitidos do Connect** card, after **Allowed IPs**. It is available for
   every application, in development and in production.
3. Turn on **Restringir onde o Connect pode ser usado**.
4. Add the origins of your websites (see [What you can list](#what-you-can-list)). If your users
   also reach Connect from a mobile app, a new tab or a redirect, keep **Permitir uso fora de um
   site** checked.
5. Save, and confirm. The policy applies to the next time Connect starts.

To turn the restriction off, use **Remover restrição** on the same card. Every change is recorded
in your team's activity log, with who made it.

<Callout variant="warning" title="List your development origins too">
  If you run your app locally, add `http://localhost:3000` (or the port you use) as well. Otherwise
  Connect is blocked on your own machine as soon as the restriction is on.
</Callout>

## What you can list

An entry is an **origin**: a scheme, a host and, if it is not the default, a port. It has no path,
query, fragment or credentials. Entries are lowercased, and the stored list is normalized.

| Entry | Valid | Notes |
| --- | --- | --- |
| `https://app.example.com` | Yes | An exact https origin. |
| `https://app.example.com:8443` | Yes | Ports must match exactly. There is no wildcard port. |
| `http://localhost:3000` | Yes | `http` is accepted only for `localhost`, `127.0.0.1` and `[::1]`. |
| `https://*.example.com` | Yes | Matches subdomains at any depth, never `example.com` itself. List the apex separately if you need it. |
| `capacitor://localhost` | Yes | Hybrid app scheme. See [Hybrid apps](#hybrid-apps). |
| `ionic://localhost` | Yes | Hybrid app scheme. See [Hybrid apps](#hybrid-apps). |
| `http://app.example.com` | No | `http` is only for localhost. Use `https`. |
| `app.example.com` | No | A scheme is required. |
| `https://app.example.com/connect` | No | No paths, queries or fragments. Use the origin only. |
| `https://*.com.br` | No | Wildcards are never allowed on public suffixes. |
| `https://*.vercel.app` | No | Same: it would allow every project hosted there. |
| `https://app.*.example.com` | No | A wildcard can only be the left-most label. |
| `http://*.example.com` | No | Wildcards are https only. |
| `file://` and `null` | No | Not supported. |

More rules:

- **Wildcards** (`https://*.example.com`) need a registrable domain after the `*.`. Public suffixes,
  including shared hosting domains such as `vercel.app`, `github.io` and `netlify.app`, are
  rejected: a wildcard there would let every site hosted on the platform embed your Connect. List
  your exact `https://your-project.vercel.app` origin instead.
- Up to **50 entries** per application, each up to 255 characters. Duplicates are not accepted.
- Pluggy's own [Dashboard](https://dashboard.pluggy.ai) previews of Connect (the demo and the
  customization preview) always work and do not need to be on your list.

### Hybrid apps

Apps built with Capacitor, Ionic and similar frameworks load your code from a custom scheme, such as
`capacitor://localhost` or `ionic://localhost`. List that origin if Connect runs inside such an app.

A custom scheme does not identify your app: **every** app built with the same framework on the
device uses the same scheme. Listing `capacitor://localhost` allows any Capacitor app to run Connect
for your application, so treat it as a weaker guarantee than an `https` origin.

### Not supported

- `file://` pages. A page loaded from the file system has no origin Pluggy can verify, so it cannot
  be allowed.
- **Android Cordova** apps served from `file://`. Their pages report no usable origin, so they are
  not supported on an application with the restriction on.

## What it does not cover

Allowed Connect domains controls where **Connect** runs. It does not protect the rest of your
integration:

- **Server-side use of a Connect Token.** A Connect Token is a bearer credential. Someone who steals
  one can use it from a server, with no web page involved, and this setting does not apply. Protect
  the endpoint in your backend that creates Connect Tokens: authenticate your users, rate limit it,
  and never expose it publicly without a session. See [Connect Tokens](/docs/security/connect-tokens).
- **Your own pages being framed.** This setting stops other sites from embedding *Connect*. To stop
  other sites from embedding *your* pages, send a `Content-Security-Policy: frame-ancestors` header
  on them. We recommend setting both.
- **A modified copy of the widget** hosted by someone else, and **top-level loads**, which are
  governed by **Allow use outside a website** and not by an origin.

### Browser caveats

Connect identifies the embedding page from signals the page itself cannot forge. In some cases
the browser does not provide them:

- **Firefox with `Referrer-Policy: no-referrer`.** Firefox does not expose the ancestor origins of a
  frame. If your page is served with `Referrer-Policy: no-referrer`, Connect cannot tell where it
  is running and blocks the load when the restriction is on. Use a policy that still sends the
  origin, such as `strict-origin-when-cross-origin` (the browser default) or `origin`, on the pages
  that embed Connect.
- **Nested frames in Firefox.** When Connect is inside a frame inside another frame, Firefox lets
  Pluggy check only the immediate parent, not the whole chain. Browsers that expose the full chain check every level.
- **Sandboxed iframes.** An iframe with `sandbox` and without `allow-same-origin` has an opaque
  origin, so it is blocked on a restricted application. Add `allow-same-origin` to the frame that
  embeds Connect.

## What your users see

When Connect is blocked, it shows a screen explaining that it cannot be used from this site, with no
connection form and no retry button. The `onError` callback of Pluggy Connect is called with
`{ message, code }`, where `code` is one of the values below.

| Situation | `onError` code | Screen |
| --- | --- | --- |
| The page is not allowed for this application | `CONNECT_EMBED_ORIGIN_NOT_ALLOWED` | A blocked screen, with no retry |
| Connect could not check whether the page is allowed | `CONNECT_CONFIG_UNAVAILABLE` | A "could not load" screen, with a retry button |


The second screen has a retry button. When Connect runs inside a web page it needs that check to
succeed before it starts, so a temporary failure shows the retry screen instead of the form. Outside
a web page, a temporary failure does not block Connect.

If you get `CONNECT_EMBED_ORIGIN_NOT_ALLOWED` on a site that should be allowed, check the exact
origin: scheme, host and port must match an entry (`https://www.example.com` is not
`https://example.com`).

## Troubleshooting

### Connect is blocked on my staging or local environment

Add that origin to the list (`https://staging.example.com`, `http://localhost:3000`), or use a
separate application for staging with no restriction. See
[Credentials and API keys](/docs/security/credentials#separate-development-production-and-tenants).

### Connect is blocked inside my mobile app

If the app loads Connect in a web view or with a Pluggy mobile SDK, turn on **Permitir uso fora de
um site**. If it is a Capacitor or Ionic app that serves its own pages, list `capacitor://localhost`
or `ionic://localhost` instead.

### I locked myself out

The Dashboard is never blocked by this setting. An `OWNER` or `ADMIN` can open the application, fix
the list or use **Remover restrição**, and the change applies the next time Connect starts.

### Is this the same as the IP allowlist?

No. The [IP allowlist](/docs/security/ip-allowlist) restricts which servers may call the Pluggy API
with your credentials. This setting restricts which websites and apps may run Connect.

Next: [Team access](/docs/security/team-access).