# Locked Ports: CORS, Sessions & Troubleshooting

> Allow CORS preflight requests on a locked port, revoke browser sessions for one Pod or an entire workspace, review workspace role permissions, security limits, and troubleshoot errors.

Source: https://docs.meshive.ai/documentation/endpoint-access-controls/

Advanced controls, role permissions, security boundaries, and troubleshooting for [Locked ports](/documentation/endpoint-access/).

## Web pages on other sites (Allow preflight)

Sometimes a web page on another site needs to call a locked port from the browser. Before it sends the real request, the browser sends a small check first, called a **CORS preflight**. It is an `OPTIONS` request, and it carries no key. A locked port refuses it, so the page shows a CORS error.

**Allow preflight** lets that one check through. It is **off** by default, and you turn it on for each port.

| Request | With Allow preflight on |
| --- | --- |
| The browser's preflight check (`OPTIONS`) | Reaches your app **without a key** |
| The real request that follows (`GET`, `POST` and so on) | Still needs an [access key](/documentation/endpoint-access-keys/) |

Your app has to answer the preflight itself, with the CORS headers that say which sites may call it. Meshive doesn't add them. If the page still gets a CORS error after you turn this on, check your app's CORS settings.

> **Caution — A key in a web page is public:**
> A key you put in a web page is visible to **everyone who opens that page**. Use a key made only for that page, and [roll it](/documentation/endpoint-access-keys/#roll-a-key) if it leaks. Turning Allow preflight on also means that `OPTIONS` requests to the port reach your app without a key, so turn it on only for ports that need it.

**Console.** Open the **Connect** tab of the Pod. In the **Access keys** section, **For web pages on another site** has one row for each locked port, with a switch named **Allow preflight**. Turning it on asks first: **Allow preflight requests on port 8000?** — *Preflight (OPTIONS) requests will reach your app without a key. A key you put in a web page is visible to everyone who opens that page — give that page its own key and roll it if it leaks.* Choose **Allow**, or **Cancel**. Turning it off needs no confirmation. The setting is kept when you unlock the port and lock it again, and it does nothing while the port is unlocked.

**CLI.** `meshive port-preflight <workspace> <pod> <port> on` (asks first; add `--yes` to skip) or `off`. `meshive pod` lists the locked ports that let preflight through.

**SDK and MCP.** `set_port_preflight(pod_name, workspace, port, allow)` in the SDK. In the [MCP server](/sdk-cli/mcp/pods/#locked-ports), `set_port_preflight` turns it on only after you say yes.

## Browser sessions

When a workspace member opens a locked port in a browser, the browser stays signed in to that port for 7 days. **Sign out all** ends those browser sessions for the Pod. It is in the **Browser sessions** section of the **Connect** tab, below **Access keys**.

Use it when a port was opened on a shared computer, or when a session may have leaked. The console asks first: **Sign out all browser sessions?** — *Members who opened this Pod's locked ports in a browser will have to enter again. Access keys keep working, and connections that are already open stay open.* After you confirm, it shows *Browser sessions signed out. This takes a few seconds to apply.*

| What | Result |
| --- | --- |
| Browser sessions on every public port of this Pod | Signed out, within a few seconds |
| Members | Go through the console again the next time they open a port. Members who are still in the workspace get back in |
| [Access keys](/documentation/endpoint-access-keys/) | Not affected. They keep working |
| Connections that are already open | Stay open until they close |
| Other Pods | Not affected |

Admins and billing members can use it. It can't be undone, and running it again does no harm.

**CLI.** `meshive pod-browser-sessions-revoke <workspace> <pod>` (asks first). **SDK and MCP.** `revoke_browser_sessions`; in the MCP server it waits for your yes.

### Every Pod in a workspace

To sign out the browser sessions of every Pod in the workspace at once, use **Sign out all** in the **Browser sessions** section at the bottom of **Settings → Team**. The console asks first: **Sign out all browser sessions in this workspace?** — *Members who opened a locked port of any Pod in this workspace in a browser will have to enter again. Access keys keep working, and connections that are already open stay open.* It works like the Pod's button, for all Pods of the workspace, and needs the same role. Removing a member from the workspace does this as well.

**CLI.** `meshive workspace-browser-sessions-revoke <workspace>` (asks first). **SDK.** `revoke_workspace_browser_sessions(workspace)`. **MCP.** `revoke_browser_sessions` with `all_pods=true` and `workspace` (and no `pod`); it waits for your yes.

## Who can change it

| Action | admin | billing | viewer |
| --- | --- | --- | --- |
| Open a locked port in the browser | Yes | Yes | Yes |
| See whether a port is locked, and list its access keys | Yes | Yes | Yes |
| Lock or unlock a port | Yes | Yes | No |
| Create, roll or revoke access keys | Yes | Yes | No |
| Turn Allow preflight on or off | Yes | Yes | No |
| Sign out all browser sessions | Yes | Yes | No |

A viewer sees the switches and buttons, but they are turned off.

## Limits to know about

> **Caution — What a lock doesn:**
> - **Connections already open stay open.** Revoking a key, removing a member or locking a port stops new requests. A WebSocket or other long-lived connection that was already open keeps running until it closes.
> - **A locked URL shows that it exists.** Someone who tries an address can tell a locked port from an address that doesn't exist, because the answers differ. They can't get in or see your app.
> - **HTTPS ends on the machine your Pod runs on.** Pods run on Meshive's own GPU hardware, and traffic to your port is decrypted on the machine that runs the Pod, so the operator of that machine can see it — as with any cloud provider. The same limit applies to **Internal** ports: Internal keeps other workspaces out, but it is not protection from the machine's operator. Give sensitive internal services their own login.
> - **Your account API key doesn't get in.** A request that carries a Meshive account API key (`meshive_...`) in `Authorization` isn't passed on to your app: Meshive removes that header. It doesn't open the port either — use an access key.
> - **Changes usually apply within a few seconds.** In rare cases, when one machine stops receiving updates, a revoked key or a removed member can keep working on that machine for up to about 20 minutes. These timings are tuned and may change.
> - **If Meshive can't enforce locks on a machine,** the locked addresses of Pods on that machine stop answering after about 20 minutes. They close; they are never opened to anyone.
> - **Changing a port number can change the URL and drop the keys.** Only a port that came with the template, moved to a number the Pod isn't using, keeps both. See [Changing a port later](/documentation/endpoint-access/#changing-a-port-later).
> - **Very old browsers can't open a locked port.** A locked port needs a browser that tells it where a request comes from. Browsers that don't — such as Safari before 16.4 — are refused. Access keys work from any program.
> - **Apps that take only a URL.** A client that can't add a header to its requests can't send an access key itself. Run [`meshive port-forward`](/sdk-cli/cli/pod-access/#meshive-port-forward) on your computer and point the app at the local address it prints, or unlock the port.

## Troubleshooting

| You might see | It means | Do |
| --- | --- | --- |
| **This port is locked** | You aren't a member of the workspace that owns the Pod | Ask a workspace admin to invite you, then open the link again |
| A redirect (`302`) to the Meshive console when you open the URL in a browser | The lock is working: the port is checking that you are a workspace member | Sign in to the console if asked; you are taken back to the page |
| A `401` or `302` response with the header `X-Meshive-Lock-Denied: 1` | The lock refused the request before it reached your app. Your app didn't send it, so don't look for the cause in your app | Send an access key, or open the URL in the browser as a workspace member |
| A browser error about CORS or a failed preflight when a page on another site calls the port | A locked port refuses preflight requests | Turn on [Allow preflight](#web-pages-on-other-sites-allow-preflight) for the port, and check your app's CORS settings. Or call the port from a server-side program with an access key, or unlock the port |
| `401` with `{"error":"unauthorized"}` in a program | The port is locked and the request has no working access key | Send an [access key](/documentation/endpoint-access-keys/) for this port, and check that it hasn't expired or been revoked |
| `401` on the background requests of an open page | Your browser sign-in to the port ended | Reload the page |
| The page loads inside another site but stays blank or shows an error | Locked ports can't be shown in an iframe on another address | Open the URL directly, or unlock the port |
| An orange **N ports are unlocked** notice on the **Connect** tab | Those ports were made before locking existed, or by an older SDK, and nobody has chosen yet | Lock them with the switch in each row, or unlock one on purpose to keep it open |
| **Locking…** or **Unlocking…** stays for a long time | Meshive hasn't confirmed the change yet | Wait a few minutes, then reload the page. Setting the switch again doesn't make it faster. Until the row says **Locked**, treat the port as open |
| The switch is turned off | You are a viewer in this workspace | Ask an admin or billing member |
