Mixed Content: blocked an insecure request on HTTPS
Last verified:
The fix
The deployed site is HTTPS. The browser blocked a request the page made to an http:// or ws:// URL.
- 1
Copy the blocked URL from the console
The message includes the
http://orws://address. Search the repo for that host, not for the words Mixed Content. It is often a default in.env, aNEXT_PUBLIC_orVITE_value, or a string the model hardcoded next tofetch. Change that one URL tohttps://orwss://. If the server does not answer on HTTPS, the browser is right to refuse. Fix the server or pick a host that has a certificate. Do not proxy the user's browser at anhttp://API to get around the block. - 2
Rebuild after you change a public env var
NEXT_PUBLIC_andVITE_values are inlined at build time. Editing the host dashboard does not change the deployment that already shipped thehttp://string. Set the value to thehttps://URL and redeploy. A Supabase project URL from the dashboard ishttps://<project-ref>.supabase.co. If the console showshttp://127.0.0.1orhttp://localhost, the deployed bundle is still pointed at your laptop. - 3
Do not confuse it with CORS
CORS says
blocked by CORS policyand namesAccess-Control-Allow-Origin. Mixed content names an insecure URL and says the content must be served over HTTPS. Adding CORS headers, a Vite proxy, orAccess-Control-Allow-Origin: *does not make the browser fetchhttp://from an HTTPS page. A proxy in the dev server also does not exist on the deployed site. - 4
Upgrade is a migration aid, not the fix for one URL
MDN's
Content-Security-Policy: upgrade-insecure-requestsrewrites HTTP URLs to HTTPS before the mixed-content check. Use it only when a lot of legacy URLs should already work on HTTPS. If that host has no certificate, the rewritten request fails instead of being blocked, and you still have to change the URL. Do not add the CSP and leavehttp://localhostin the production bundle.
Why it happens
MDN describes mixed content as a page loaded over HTTPS that then asks for something over HTTP. Browsers upgrade image, audio, and video requests from http:// to https://. They block the rest: scripts, stylesheets, fonts, fetch, and XMLHttpRequest. A secure page that opens ws:// is the same class of problem. The console names the page URL and the blocked URL. The request never reaches your API, so a CORS header on the server cannot help.
Localhost hides it. http://localhost:3000 calling http://localhost:54321 is not mixed content, because the page itself is not a secure origin. The Vercel or Netlify URL is HTTPS. A generated client that still has http:// in an API base, a Supabase URL, an image host, or a webhook target fails only after deploy. An address written as an IP (http://1.2.3.4/...) is not upgraded even for images. MDN says those requests are blocked.
The next error you'll probably hit
Once this is fixed, the usual follow-up is has been blocked by CORS policy. This request has been blocked by CORS policy. The API sent no Access-Control-Allow-Origin for this page. Allow that origin on your server, or proxy it.
Prompt to paste back into your AI tool
Paste this above the error.
The deployed HTTPS site logs: Mixed Content: The page at '<page url>' was loaded over HTTPS, but requested an insecure resource '<blocked url>'. This request has been blocked; the content must be served over HTTPS. Do not add Access-Control-Allow-Origin. Do not set the production API URL to http://localhost. Do not add upgrade-insecure-requests and leave the http:// URL in the code. 1. Find the string that becomes <blocked url>. Change http:// to https:// or ws:// to wss://. If that host has no TLS, say so and stop. 2. If the value comes from NEXT_PUBLIC_ or VITE_, tell me to set the https URL in the host and redeploy. Those are inlined at build time. 3. If the blocked host is localhost or 127.0.0.1, the deployed bundle is using a local URL. Point it at the hosted https URL. 4. Change only that URL. Do not rewrite the fetch layer.
Common questions
+The image still appears, but the console mentions mixed content. Did the browser block it?
MDN says browsers upgrade image, audio, and video requests to HTTPS, and block other types. An upgraded image can still load. A blocked fetch will not. If the upgraded image 404s, the file is not available on HTTPS and the src still has to change.
+It works in npm run dev and fails on the Vercel URL. Is the API down?
Usually no. Dev is an HTTP origin, so the browser allows the HTTP API. The deployed page is HTTPS, so the same http:// call is mixed content. Read the blocked URL in the console.
Related errors
- has been blocked by CORS policyThis request has been blocked by CORS policy. The API sent no Access-Control-Allow-Origin for this page. Allow that origin on your server, or proxy it.CursorLovableBoltNext.jsNodeOct 14, 2026
- process.env.NEXT_PUBLIC_ is undefinedprocess.env.NEXT_PUBLIC_ is undefined. The name is missing from .env.local, it has no NEXT_PUBLIC_ prefix, or Next.js has not been restarted since you added it. Do not put a secret on that prefix.CursorLovableBoltNext.jsVercelNov 3, 2026
- supabaseUrl is requiredsupabaseUrl is required: createClient got an empty URL or key, missing when the bundle was built. Set the Supabase URL and anon key, then rebuild.CursorLovableBoltSupabaseNext.jsOct 19, 2026
- Lovable or Bolt published blank pageLovable or Bolt published blank page: publish succeeded and the preview still runs. Fix the first console error, or the script that came back as HTML.LovableBoltViteReactOct 20, 2026