Skip to content
  1. LuzineDebug
  2. Web, HTML & CSS
  3. Mixed Content: The page at 'https://example.com/…
Web, HTML & CSS Beginner ≈ 10 min to fix

Fix "Mixed Content: … requested an insecure resource" (HTTPS mixed content)

Error message
Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure resource 'http://example.com/api/users'. This request has been blocked; the content must be served over HTTPS.
  • Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure script 'http://cdn.example.com/app.js'. This request has been blocked; the content must be served over HTTPS.
  • Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://example.com/css/app.css'. This request has been blocked; the content must be served over HTTPS.
  • Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure element 'http://example.com/img/logo.png'. This request was automatically upgraded to HTTPS.
  • Blocked loading mixed active content “http://example.com/js/app.js”
  • Mixed Content: The page at 'https://example.com/login' was loaded over a secure connection, but contains a form that targets an insecure endpoint 'http://example.com/login'.
In short

Your page is served over HTTPS but loads a script, stylesheet, API call or form over http://, and the browser blocks that request. Replace the http:// URLs with https:// (or relative paths) and, behind a proxy or Cloudflare, make the application aware it runs over HTTPS so it generates the right URLs.

Be the first to confirm this fix

What this error means

An HTTPS page guarantees its content was not read or modified in transit. If it loads a resource over plain HTTP, an attacker on the network could replace that script or API response and take over the page. Browsers therefore block "active" mixed content (scripts, CSS, fetch, iframes, form targets). For images, audio and video, Chrome tries an automatic upgrade to HTTPS and no longer displays them if the server does not answer over HTTPS. The error always names the offending URL: that is what you need to fix, in the code or in the configuration that generates it.

Common causes

  1. Application behind a proxy, load balancer or Cloudflare: the proxy terminates HTTPS and talks HTTP to the application, which then generates http:// URLs (assets, redirects, url()).
  2. Hard-coded URLs in code or configuration: APP_URL=http://…, a VITE_API_URL or NEXT_PUBLIC_API_URL variable set to http://, a <script src="http://…"> tag.
  3. Content stored in the database: a site moved to HTTPS (WordPress, CMS) whose posts still contain http:// images and links.
  4. Third-party resource without HTTPS: an old CDN, widget or API that only answers over HTTP.

Step-by-step fix

  1. Find the offending URLs

    Open DevTools (F12) > Console: each message gives the blocked URL. Then check that the resource is really available over HTTPS.

    bash
    curl -sI https://example.com/api/users | head -n 1
  2. Fix the URLs in the code

    Replace http:// with https://, or use a relative path (/api/users) for resources on your own domain. Also look in the .env files used at build time.

    bash
    grep -rn "http://" src/ resources/ .env* --exclude-dir=node_modules
  3. Laravel behind a proxy: trust the headers

    The proxy sends X-Forwarded-Proto: https. Laravel only reads it if the proxy is trusted (Laravel 11+ in bootstrap/app.php). Also set APP_URL=https://example.com. Only trust * if the application can only be reached through the proxy; otherwise list its IP addresses.

    php
    // bootstrap/app.php
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->trustProxies(at: '*');
    })
    
    // app/Providers/AppServiceProvider.php, in boot()
    if ($this->app->environment('production')) {
        \Illuminate\Support\Facades\URL::forceScheme('https');
    }
  4. WordPress or CMS: rewrite the URLs in the database

    With WP-CLI, replace the old URL across the whole database (back it up first). --dry-run first shows what would change.

    bash
    wp db export backup.sql
    wp search-replace 'http://example.com' 'https://example.com' --all-tables --dry-run
    wp search-replace 'http://example.com' 'https://example.com' --all-tables
  5. Safety net: upgrade-insecure-requests

    This CSP directive tells the browser to upgrade every request of the site to HTTPS. It only works if the resources exist over HTTPS, and it does not replace fixing the URLs.

    xml
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Never hard-code the protocol for your own resources: use relative paths or the framework helpers (asset(), url(), @vite).
  • Enable HSTS (Strict-Transport-Security) once the whole site is on HTTPS, so the browser never uses HTTP again.
  • Test your staging environment over HTTPS, behind the same kind of proxy as production.

Frequently asked questions

Why does it work locally but not in production?

Locally you are often on http://localhost, so nothing is mixed. In production the page is HTTPS and every http:// resource gets blocked, especially if the application behind a proxy still thinks it runs over HTTP.

Can I allow mixed content in the browser?

Chrome lets you allow it per site (Site settings > Insecure content), but only for you and at the cost of exposing the page to code injection. It is not a fix for your visitors: correct the URLs.

What if the third-party API only exists over HTTP?

Call it from your server (a back-end proxy route) and expose the result over HTTPS on your own domain, or pick another provider.

Useful tools for this error

More Web, HTML & CSS errors

All Web, HTML & CSS errors →