Browser troubleshooting

Check whether a page is a secure context

Use window.isSecureContext when diagnosing an API that requires a trustworthy context. HTTPS is the usual deployed requirement, while browsers can also treat certain local development contexts as trustworthy.

Worked example

Browser console example · use a disposable page on your own site

console.log("Secure context:", window.isSecureContext);
console.log("Protocol:", location.protocol);
console.log("Origin:", location.origin);

How it works

The flag reports the context’s security classification rather than guessing from a URL prefix. Some powerful APIs are unavailable outside secure contexts. Checking it alongside protocol and origin helps explain differences between a local demo, an iframe, and a deployed page.

Limits and mistakes

A secure context does not guarantee permission for every API or establish that the site’s content is safe. Embedding and permission policy can impose other restrictions. Fix the deployment context rather than telling visitors to weaken browser security.

Check the result

Compare the result on the actual failing page and a correctly served local or HTTPS page. Then inspect the specific API’s requirements and rejection reason.

Sources

Reference documentation for the behavior used in this guide: