Mixed Content: the page was loaded over HTTPS, but requested an insecure resource — fix after deploy
Mixed Content: The page at 'https://…' was loaded over HTTPS, but requested an insecure resource 'http://…'. This request has been blocked means your HTTPS page asked for a script, stylesheet or API call over plain http://, and the browser refused. After a deploy the usual reasons are an API address with http:// baked into the frontend build, or a backend behind an HTTPS proxy that builds its URLs with http://. Use https:// or relative URLs, rebuild, and make the backend trust its proxy.
By Livops team, the people who build and run LivopsUpdated
What the browser console shows, on a page that loads but stays empty or half-working after the deploy[2]:
Mixed Content: The page at 'https://shop.example.com/' was loaded over HTTPS, but requested an insecure resource 'http://api.example.com/products'. This request has been blocked; the content must be served over HTTPS.
The word after “insecure” tells you what was asked for: resource for fetch(), XMLHttpRequest endpoint for Axios and other XHR clients, script, stylesheet, frame or font[2]. Images get a softer line, ending in “This request was automatically upgraded to HTTPS”[2].
This page explains which requests a browser blocks and which it upgrades, finds the http:// address in the four places it usually comes from after a deploy, gives the fix for Vite, Laravel, Django and Express, and shows where the upgrade-insecure-requests header helps and where it does not.
What does the error mean?
Mixed content is a page loaded securely that fetches resources over HTTP or another insecure protocol[1]. Browsers sort it in two groups[1]:
- Upgradable: images, audio and video. The browser changes the address from
httptohttpsby itself, and the server answers with the file or with “not found”. A request whose host is an IP address rather than a domain name is blocked instead of upgraded. - Blockable: everything else, including
<script src>, stylesheets in<link href>,<iframe src>,fetch()andXMLHttpRequest. These are blocked.
So the page loads, but its JavaScript bundle, its styles or its API calls do not, and the app looks broken without a server error anywhere.
Why you never saw it locally: the page was http://localhost, nothing on it was secure, so nothing was mixed. And content from loopback addresses such as http://127.0.0.1/ or http://localhost/ counts as secure even on an HTTPS page[1]. Only the deployed site, on https://, shows it.
The fix MDN gives: serve everything over HTTPS, make references to your own domain relative or https://, and use the HTTPS version of resources on other sites[1].
Causes, most common first
1. The API address is baked into the frontend build
The frontend reads its API address from a variable, and in production that variable says http://. In Vite, import.meta.env values are statically replaced at build time, and only variables prefixed with VITE_ reach client code[4]:
const api = import.meta.env.VITE_API_URL; // the value is written into the bundle at build time
fetch(`${api}/products`);
Changing the variable on a running site changes nothing: the old address is already in the built files. Fix: set the variable to https:// and build again.
VITE_API_URL=https://api.example.com
Two traps. vite build reads .env.production if there is one[4], so an http:// value committed there comes along. And variables already set where Vite runs have the highest priority and are not overwritten by .env files[4], so an old value in the build environment beats a fixed .env.production. Keep secrets out of VITE_ variables altogether: they end up in the bundle[4].
If the API is on the same domain, the simplest fix is no domain at all: fetch("/api/products") follows the page’s own scheme.
2. A hard-coded http:// in the code or the HTML
A script tag for a CDN, a font, a widget, an <iframe> for a map, or an API base written straight into the code. Find every one in the build output:
npm run build
grep -rnoE "http://[^\"' )]+" dist/ | grep -v "www.w3.org"
The www.w3.org lines are SVG and XML namespace names, not requests; everything else is a candidate. Change your own domain’s addresses to relative paths, and other sites’ addresses to their https:// versions[1]. If a third party has no HTTPS version, it cannot be loaded on an HTTPS page; host the file yourself or replace it.
3. The backend builds its URLs with http:// behind the HTTPS proxy
The page and its first request are fine, but the API answers with absolute URLs that start with http://: image URLs, next links in paginated responses, file download links. The browser then blocks those.
The reason is the proxy in front of the app. It takes the visitor’s HTTPS connection and passes the request on over plain HTTP, so the framework believes the request was HTTP and builds URLs to match. Each framework has a setting that makes it read the original scheme from the proxy’s header, and each comes with the same caution: trust the header only if your proxy sets it and a visitor cannot forge it.
Laravel. Behind a load balancer that terminates TLS, Laravel sometimes does not generate HTTPS links, because traffic arrives on port 80[5]. Trust the proxy in bootstrap/app.php; * trusts all of them when you do not know their addresses[5]:
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*');
})
Laravel builds URLs with the request’s own scheme unless one is forced, and URL::forceScheme('https') or URL::forceHttps() forces HTTPS for every generated URL[6]. The proxy setting is the better fix, because it also makes the request itself count as secure.
Django. Behind a proxy that talks plain HTTP to Django, is_secure() returns False even for requests the visitor made over HTTPS[7], and build_absolute_uri() always uses the scheme of the current request[8]. The setting:
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
Django’s warning is strict: set it only if the app is behind a proxy, the proxy strips X-Forwarded-Proto from all incoming requests, and sets it only for requests that came in over HTTPS; otherwise keep it None[7].
Express. req.protocol uses the X-Forwarded-Proto header only when the trust proxy setting is not false[10], and req.secure is req.protocol === 'https'[10]. By default it is false, and the app is understood as facing the client directly[9]:
app.set("trust proxy", 1); // trust the first proxy in front of the app
app.get("/products", (req, res) => {
const base = `${req.protocol}://${req.hostname}`; // https once the proxy is trusted
// ...
});
A number means the addresses at most that many hops away[9]. If you set it to true, the last trusted proxy must remove or overwrite X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto, or a client could supply any value[9].
The same mistake shows up in the HTML a server renders: a form action or a stylesheet link built with http://. With Laravel the visible symptom is often a 419 Page Expired on every form, because the form posts to http:// and the secure session cookie stays behind.
4. Old http:// URLs stored in the database
A CMS, a blog or a shop that ran on http:// before stores full image URLs inside its content. The images may still show, because browsers upgrade them[1], as long as the same address answers over HTTPS; embedded scripts and frames in that content are blocked. Fix the data, not the template. Back up first, then for each table and column that holds content:
UPDATE posts
SET body = REPLACE(body, 'http://shop.example.com/', 'https://shop.example.com/');
For new content, store paths such as /uploads/photo.jpg rather than full URLs.
A stopgap: upgrade-insecure-requests
One header tells the browser to treat all of the page’s http:// URLs as if they were https://[3]:
Content-Security-Policy: upgrade-insecure-requests
or, if you cannot set headers, in the page’s <head>[3]:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />
It is meant for sites with many legacy http:// URLs that still need rewriting[3]. What it does not do:
- It has no fallback. If the resource is not available over HTTPS, the request fails[3].
- Links to other sites stay as they are. Subresource requests are upgraded, first-party and third-party alike, but navigation to third-party addresses is not[3].
- It does not replace HSTS, which you still want against SSL stripping[3].
Use it to stop the bleeding while you fix the addresses in causes 1 to 4, not instead of fixing them.
How to confirm the fix
-
Open the deployed site with the browser’s developer tools on the Console tab and reload. No line may start with
Mixed Content. -
On the Network tab, filter by
http://; no request should be left. -
Check what the API returns, not only the page:
curl -s https://api.example.com/products | grep -o '"http://[^"]*"' | headAn empty result means the backend builds
https://URLs. Any line is cause 3 or 4.
On Livops
-
Every address is HTTPS. Every project gets a
<name>.livops.appaddress with HTTPS, and a domain you connect gets its certificate automatically as soon as it is live. Nothing to configure; what is left is thehttp://addresses inside your code, variables and data. -
In the docs too. Livops’s docs on a page that opens blank cover this case: on an HTTPS page the browser blocks scripts over
http://; usehttps://or a path on the same site. See The page loads files over http://. -
Static site variables are build variables. A static site reads
VITE_*,NEXT_PUBLIC_*and similar variables at build time, and they are baked into the files, visible to anyone. FixVITE_API_URLin the service’s Variables and deploy again: new values take effect on the next deploy. When a staging release of a static site is promoted, it is rebuilt from the same commit with production’s variables, so check the production value too. -
Not
localhosteither. An API address ofhttp://localhost:8000is the visitor’s own computer once deployed; see The frontend calls localhost. -
The CSP header on a static site goes in a
_headersfile at the root of the build output (public/_headersbecomesdist/_headers):/* Content-Security-Policy: upgrade-insecure-requestsFor a web app, send the header from the app itself.
-
Proxy settings only on evidence. Before you set
trustProxies,SECURE_PROXY_SSL_HEADERortrust proxy, check which header reaches your app: log the request headers once from a test route.
Forms failing after the same deploy: 419 Page Expired in Laravel, Django CSRF verification failed. A static site that answers 404 on refresh: 404 on page refresh in a React or Vue app.
Questions
Why does it work locally and break after deploy?
Locally the page is served over http://localhost, so nothing on it is mixed, and browsers treat loopback addresses such as localhost as secure anyway. In production the page is HTTPS, and any http:// address it still uses, from a build variable, a hard-coded link or the backend's own URLs, is now blocked.
Why are some images still shown while my API calls are blocked?
Browsers upgrade images, audio and video from http:// to https:// by themselves, and block everything else that is mixed: scripts, stylesheets, frames, fetch and XMLHttpRequest. An image shows if the same address works over https; it fails if it does not, or if its host is an IP address.
I changed VITE_API_URL to https but the site still calls http. Why?
Vite replaces import.meta.env values in the code at build time, so the old address is written into the built files. Change the variable where the build runs and build again; a restart is not enough. Also check that no other variable or .env file with the old value takes priority.
Can I just add upgrade-insecure-requests and move on?
It works as a stopgap: the browser rewrites the page's http:// requests to https://. But a request fails if the resource is not available over HTTPS, links to other sites are not upgraded, and the wrong URL is still in your code and data. Fix the source, then keep or drop the header.
Is trusting the proxy safe?
Only when the proxy is the only way to reach your app and it sets the forwarding headers itself. Django and Express both warn that a client could otherwise send a forged X-Forwarded-Proto and make a plain HTTP request look secure.
Does Livops need any setting to serve my site over HTTPS?
No. Every project gets a livops.app address with HTTPS, and a domain you connect gets its certificate automatically once it is live. What you fix is the http:// addresses inside your own code, variables and data.
Sources
- MDN — Mixed content (developer.mozilla.org). Checked .
- Chromium source — mixed_content_checker.cc (raw.githubusercontent.com). Checked .
- MDN — CSP upgrade-insecure-requests (developer.mozilla.org). Checked .
- Vite — Env Variables and Modes (vite.dev). Checked .
- Laravel docs — HTTP Requests, Configuring Trusted Proxies (13.x) (laravel.com). Checked .
- Laravel source — Routing/UrlGenerator.php (13.x) (raw.githubusercontent.com). Checked .
- Django docs — Settings (SECURE_PROXY_SSL_HEADER) (docs.djangoproject.com). Checked .
- Django docs — Request and response objects (docs.djangoproject.com). Checked .
- Express — Express behind proxies (expressjs.com). Checked .
- Express 5.x API — Request (expressjs.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your site with HTTPSRelated
- 419 Page Expired in Laravel after deploy: CSRF token mismatch, fixed419 Page Expired is how Laravel answers a POST whose CSRF token does not match the one in the session (TokenMismatchException, CSRF token mismatch.). After a deploy it usually means the session cookie never came back: the form posts to an http:// address because Laravel does not trust the HTTPS proxy, or SESSION_DOMAIN, SESSION_SECURE_COOKIE or SESSION_DRIVER is wrong for production. Otherwise the form lacks @csrf or the AJAX call lacks X-CSRF-TOKEN.
- Forbidden (403) CSRF verification failed. Request aborted. — Django after deployForbidden (403) CSRF verification failed. Request aborted. means Django's CSRF middleware refused a POST. Right after moving behind HTTPS and a proxy, the usual reason is Origin checking failed: add the site's origin with its scheme, such as https://example.com, to CSRF_TRUSTED_ORIGINS. For CSRF cookie not set or CSRF token missing, put the csrf_token tag in the form or send the X-CSRFToken header.
- 404 on page refresh in a React or Vue app (SPA): how to fix itA 404 when you refresh a page or open a link like /about in a React Router or Vue Router app means the static host looked for a file at /about, found none, and never loaded index.html, where the router lives. Fix it on the host by rewriting every route to /index.html (Netlify _redirects, Vercel rewrites, nginx try_files), or switch to hash routing. The price of a rewrite: unknown paths stop being 404s unless the app shows its own.
- Free static site hosting in 2026: the free tiers comparedA static site — plain HTML, or a Vite, React or Astro build, or a Lovable export — is free on all five. The differences are the limits: Netlify pauses every site when 300 monthly credits run out, Vercel Hobby is for non-commercial use only, GitHub Pages is not for running a business, and Cloudflare Pages does not count static traffic. On Livops up to 30 sites are free, on your own domain, with no card asked for.
- Express.js hosting in 2026: the options comparedAn Express app in production needs one long-running Node process that listens on process.env.PORT on every interface, trusts exactly the proxy in front of it, exits cleanly on SIGTERM, and keeps sessions and data in a database rather than in memory. On Livops an Express repository deploys from a push for 39 credits a month (39,000 so'm). Here is how Render, Railway, Fly.io, Vercel and a VPS with pm2 compare.
- Django hosting in 2026: how to deploy a Django app, and whereFor most Django apps, a platform that deploys from Git is the right pick: Render and DigitalOcean App Platform are the simplest fixed monthly prices, Fly.io is the cheapest in dollars, Railway bills by usage, and a VPS is for when you want root. Livops fits Django apps whose users are in Uzbekistan, at 39 credits a month. Below: prices and free tiers side by side, a Django deployment checklist, and how to host a Django project on Livops.