Mixed Content: requested an insecure resource
Your secure https page tried to load data or code over plain http, and the browser blocked that request to keep the page secure.
Also appears as
- Mixed Content: The page at 'https://my-app.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.example.com/items'. This request has been blocked; the content must be served over HTTPS.
- Blocked loading mixed active content “http://api.example.com/items”
- [blocked] The page at https://my-app.com/ requested insecure content from http://api.example.com/items. This content was blocked and must be served over HTTPS.
Prompt to fix it
My published site logs "Mixed Content: ... requested an insecure resource" in the browser console. Find every http:// URL the app requests, in code, config, and environment variables, and switch each to https:// or a relative path. If the code already uses https, check whether the server redirects to http, for example a trailing-slash redirect behind a proxy, and fix that redirect on the server. If the API has no HTTPS at all, tell me. Don’t ask users to allow insecure content in their browser settings.
Paste into Layerwise or any AI coding tool.
What it means
A page served over https:// is encrypted. If it calls an http:// URL, that request would travel unencrypted, where anyone on the network could read or change it. Browsers block such requests for API calls, scripts, and frames, and the fetch call then fails with Failed to fetch. Chrome upgrades images and media to https:// on its own, so API calls are where this usually shows up.
It almost always appears right after publishing. Locally, everything runs on http://localhost, so an http:// API URL works. After deploy the page is on HTTPS, and the same URL is suddenly blocked.
Sometimes the code already uses https:// and the error still names an http:// URL. That happens when the server redirects, for example to add a trailing slash, and builds the new URL with http:// because it sits behind a proxy that handles HTTPS. The Network tab shows that redirect.
Common causes
- The API base URL in the code or an environment variable starts with
http://. - The backend redirects to an
http://address, often a trailing-slash redirect behind a proxy. - The API server has no HTTPS at all, such as a bare IP address or a server without a certificate.
- A hardcoded script, iframe, or stylesheet URL uses
http://.
How to fix it
- Note the exact
http://URL named in the console message. - Change it to
https://, usually in the API URL environment variable on your host, then redeploy. - If the code already uses
https://, look for a redirect tohttp://in the Network tab. Fix it on the server, for example by trusting the proxy’s forwarded headers, or call the final URL directly. - If the server has no HTTPS, put it behind a host or proxy that provides a certificate, such as Cloudflare or Caddy.
- Call your own backend with relative URLs like
/api/itemswhen it shares the site’s domain, so the scheme always matches.
Example fix
# Blocked on the published https site:
# VITE_API_URL=http://api.example.com
VITE_API_URL=https://api.example.comRelated errors
All errorsFailed to fetch
The browser never got a usable response: the server was unreachable, or the browser blocked the request or its reply.
ERR_TOO_MANY_REDIRECTS
The site keeps redirecting the browser in a circle, usually between HTTP and HTTPS or between two domains, so the browser stops trying.
Blocked by CORS policy
The browser hid a response from another site because that server never said your site is allowed to read it.
Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Your code expected JSON, but the server sent back an HTML page, usually a 404 page or your app’s own index.html.
Build with an agent that checks its work
The Layerwise agent clicks through the live preview and reads the console, so it catches errors before you do.