![Yifan Luo](https://web.dev/images/authors/lyf.jpg) Yifan Luo [GitHub](https://github.com/ivanlish)

<br />

> [!NOTE]
> **Note:** The [PNA rollout is on hold](https://developer.chrome.com/blog/pna-on-hold.md.txt). Therefore this trial is expected to end with Chrome 132.

## Background

Chrome 94 introduced a block on private network access from non-secure public websites. The ongoing [Private Network Access from non-secure contexts deprecation trial](https://developer.chrome.com/origintrials#/view_trial/4081387162304512001) has revealed challenges in migrating affected websites to HTTPS. A common concern is the difficulty of migrating private devices to HTTPS, leading to mixed content check violations.

To address the previously mentioned challenge, a new permission prompt is available under an [origin trial](https://developer.chrome.com/origintrials#/view_trial/1367968386813788161) from Chrome 120

## Permission prompt as the new option

By adding the new `targetAddressSpace` attribute as a fetch option, the request will be able to skip the mixed content check.

Example:

```text
fetch("http://router.local/ping", {
  targetAddressSpace: "private",
});
```

> [!NOTE]
> Note: Local IP addresses like `127.0.0.0/8` and `::1/128` ([RFC4632](https://www.rfc-editor.org/rfc/rfc4632)) are considered [potentially trustworthy](https://www.w3.org/TR/secure-contexts/#is-origin-trustworthy) in mixed content checks, therefore the permission prompt is not required in these cases.

In accordance with the [Private Network Access: introducing preflights](https://developer.chrome.com/blog/private-network-access-preflight.md.txt), any private network request will be preceded by a preflight request. This preflight request will include a new header, `Access-Control-Request-Private-Network: true`, and the corresponding response must include the header `Access-Control-Allow-Private-Network: true`.

To accommodate the new permission prompt, we required devices to incorporate two new response headers: `Private-Network-Access-Name` and `Private-Network-Access-ID`.

```text
Private-Network-Access-Name: <some human-readable device name>
Private-Network-Access-ID: <the MAC address of the device>
```

Example:

```text
Private-Network-Access-Name: "My Smart Toothbrush"
Private-Network-Access-ID: "01:23:45:67:89:0A"
```

`Private-Network-Access-ID`: A 48-bit value presented as 6 hexadecimal bytes separated by colons.
`Private-Network-Access-Name`: A valid name as a string that matches the ECMAScript regular expression `/^[a-z0-9_-.]+$/`. The maximum length of the name is 248 UTF-8 code units.

> [!NOTE]
> Note: When the mixed content check has been bypassed for the private network permission prompt, the preflight will be enforced, even under the preflight warning mode.

## Demo

You can check out the demo at: <https://private-network-access-permission-test.glitch.me/>.

## Register for an origin trial

To ensure that Private Network Access Permission Prompt helps developers adopt secure context restrictions for private network access, we are making them available in Chrome from version 120 to 122 as an origin trial.

Register for the origin trial to enable your website to use the permission prompt:

1. [Request a token](https://developer.chrome.com/origintrials#/view_trial/1367968386813788161) for your origin.
2. Use the token in one of the following ways:
   - In your HTML: `html
     <meta http-equiv="Origin-Trial" content="TOKEN_GOES_HERE">`
   - In your JavaScript: `js
     const meta = document.createElement('meta');
     meta.httpEquiv = 'Origin-Trial';
     meta.content = 'TOKEN_GOES_HERE';
     document.head.append(meta);`
   - In the HTTP headers: `text
     Origin-Trial: TOKEN_GOES_HERE`

For any feedback or suggestions regarding this feature, please file an issue in the [GitHub repository](https://github.com/WICG/private-network-access).

## Resources

- [Private Network Access Permission Prompt Spec](https://wicg.github.io/private-network-access/#permission-prompt)
- [Private Network Access Permission Prompt Explainer](https://github.com/WICG/private-network-access/blob/main/permission_prompt/explainer.md)
- [Walk through relaxing mixed-context for private network access](https://docs.google.com/document/d/1W70cFFaBGWd0EeOOMxJh9zkmxZ903vKUaGjyF-w7HcY/edit?usp=sharing):