A website calling localhost: separate the browser’s security boundaries
A public page reaching a local companion service crosses a sensitive boundary. Loopback binding alone does not make that service safe from hostile web pages. The outcome depends on the request API, source and destination origins, browser version, permission state, certificate trust and local service policy. The original article’s universal 2025 browser matrix is not a reliable compatibility test.
PNA and LNA are not interchangeable
Chrome’s Local Network Access announcement says its permission-based approach replaces the earlier Private Network Access experiment, which was put on hold. The announcement’s September 2025 update names Chrome 142 for launch; this does not mean all traffic had mandatory PNA preflights since Chrome 94.
The Chrome 147 release notes document local-network restrictions for WebSockets and WebTransport, including permission prompts. Thus the earlier blog’s first-milestone exclusions are historical, and WebTransport is not a general escape from local-network permission. These are documented versioned changes, not a claim that this article tested every current Chrome, Edge, Firefox or Safari build.
Check the layers separately
| Boundary | What to check |
|---|---|
| Transport and secure context | HTTPS/WSS protect transport, but certificate validity, browser rules and the destination still matter. Loopback can be potentially trustworthy without ordinary network TLS. |
| HTTP CORS | Controls cross-origin response access and some preflights; it is not service authentication or a universal prevention of sending requests. |
| Local-network permission | An independent browser gate may apply to private/local/loopback destinations. A CORS or historical PNA header does not grant user permission. |
| WebSocket Origin | Validate Origin and authenticate the session at the server. WebSocket is not ordinary fetch CORS. |
| Application authorization | Check the identity, allowed operation and anti-CSRF/session binding even for loopback clients. |
The Secure Contexts specification treats loopback and qualifying localhost names specially. Mixed Content rules depend on potentially trustworthy URLs, not simply whether a string starts with HTTP. An HTTP page requesting HTTP is not automatically “mixed content”; nevertheless other security rules may block it. Do not turn a secure public page into HTTP as a workaround.
HTTP fetch and an illustrative CORS response
For an allowed cross-origin request, a local HTTP server might return an exact approved origin such as the following. This is an illustrative response header, not a complete server configuration and not a promise that the browser will allow the connection. Only emit it after checking the origin against a configured allowlist; do not reflect arbitrary origins.
Access-Control-Allow-Origin: https://app.example
Vary: Origin
app.example is a reserved documentation hostname, not the user’s deployment. Credentialed requests, allowed methods and headers, preflight handling and anti-CSRF protections require an application-specific design. The historical Access-Control-Allow-Private-Network: true exchange in the source is preserved only as archival code in the faithful translation, not as a universal modern fix. See the Fetch standard for CORS processing.
WebSockets require server-side checks too
A wss:// URL does not mean “CORS only” or guaranteed connectivity. The server should validate the browser’s Origin against its explicit policy and authenticate and authorize the session; non-browser clients can forge Origin, so it is not an identity credential. See RFC 6455. Local-network permissions and mixed-content behavior remain separate browser checks. Do not assume an HTTP OPTIONS PNA exchange precedes every WebSocket connection.
Which architecture options remain useful?
- HTTPS on both sides: use correctly issued and validated certificates where appropriate. It does not override local-network permissions or application authorization. Do not disable certificate checks or add a root certificate to a user’s trust store merely as a troubleshooting shortcut.
- Local hosting: serving the UI and API from the exact same origin can simplify CORS. Scheme, host and port all matter. Other web pages may still target the local service, so validate host/origin and protect state-changing operations.
- WebTransport: choose it only for its actual transport needs and supported clients, not to bypass security restrictions.
- Managed policies: enterprise allowances or blocks are security-administrator decisions for named approved sites, not instructions to loosen a user’s settings. No policy was changed here.
- HTTP downgrade: do not sacrifice HTTPS on a public site to chase permissive behavior in one browser.
Replace the old browser matrix with a verification plan
Record exact browser/build and operating-system versions; test Chrome, Edge, Firefox and Safari independently where supported. Cover HTTP and WebSocket requests, intended origins/ports, local-network permission allowed and denied, valid and invalid certificates, unauthorized Origin and unauthenticated operations. Check console, network and local-service logs without publishing private data. No browser or runtime tests were performed for this article.
Original archive attribution: Alex R., Coding with Alex. The useful conclusion is to design explicit local-service authorization and verify the intended deployment, not rely on a blanket “allowed/blocked” cell or a single response header.