Map or captcha dead live? Allow the domain

You built the site in Lovable, Bolt, Replit, v0 or Cursor. In preview the map loads, the captcha ticks, and the contact form sends. Then you connect your real domain, and the map turns grey with a "This page can't load Google Maps correctly" box, or the captcha shows an error and the form will not submit. Nothing in your code changed, and nobody gets an alert.

The symptom

Something that depends on a third-party key works on one address and fails on another. Common versions:

  • A Google map shows a dark overlay or a "For development purposes only" watermark, or does not render at all.
  • A reCAPTCHA box says the domain is not valid for the site key, so the form cannot be sent.
  • A Cloudflare Turnstile widget shows an error instead of the check, and sign-up or contact forms stay blocked.

The tell is that the same build works on the preview URL and breaks on the custom domain, or the other way round.

The cause

Many browser-side keys are locked to a list of allowed domains. That is good security: a key that ships in your page source can be copied, so the provider only honours it on the hostnames you listed. When you first set the key up, you probably added whatever address you were testing on, such as the builder's preview subdomain or localhost. Your custom domain was never added, so the provider rejects every request from it.

The reverse also happens: someone removes the preview address, so preview breaks while live works. Either way, the allowed hostnames and the address bar do not match.

Step-by-step diagnosis

  1. Open the live page in a private window and open the browser developer tools (right-click, Inspect, then the Console tab).
  2. Reload and read the errors. Google Maps reports RefererNotAllowedMapError when the domain is not allowed. reCAPTCHA shows an "Invalid domain for site key" message inside the widget. Turnstile logs an error code in the console; a domain problem points to the hostname not being allowed for that widget.
  3. Note the exact hostname in the address bar. Is it www.yourdomain.com or yourdomain.com? Providers treat those as different unless you allow both or use a wildcard.
  4. Compare with the provider's settings. In Google Cloud Console, open the API key and look at Website restrictions. In the reCAPTCHA admin console, open the site and check Domains. In the Cloudflare dashboard, open the Turnstile widget and check Hostname management.
  5. Confirm it is the same key. If your live build reads the key from an environment variable, make sure production has the key you are looking at, not an old test key.

Fixes per builder or host

Lovable

Your site is reachable on its Lovable subdomain and on any custom domain you connected. Add both to the key's allowed list if you want both to work. If the key lives in project settings or secrets, check that the published version uses the same value.

Bolt

Bolt projects are often deployed to Netlify. Add the Netlify subdomain and your custom domain. If you set the key as an environment variable in Netlify, redeploy after changing it so the new build picks it up.

Replit

The development URL and the deployment URL are different hostnames. Add the deployment hostname and your custom domain, not only the address you used while building.

v0 and Vercel

Vercel gives every preview deployment its own URL. Rather than adding each one, allow your production domain and, if you need previews to work, a wildcard pattern for your project's preview hostnames where the provider supports it.

Cursor or a custom setup

Whatever host you use, list every hostname that serves the page: apex, www, and any staging address. Keep localhost on a separate development key if you can, so your production key stays tight.

How to verify

  • Save the new restrictions and allow a few minutes for them to apply.
  • Reload the live page in a private window and check the Console tab is free of the domain error.
  • Actually use the feature: pan the map, solve the captcha, and submit the form end to end.
  • Repeat on both www and the bare domain, and on mobile data, not just your office network.

Prevention

  • Keep a short list of every third-party key the site uses and which hostnames each allows. Update it the day you add or change a domain.
  • Make domain changes a checklist item. Connecting a custom domain, adding www, or moving hosts should always trigger a review of key restrictions.
  • Do not remove restrictions to make the error go away. An unrestricted key in public page source can be copied and run up usage on your account.
  • Watch the live page, not the preview. These failures only appear on the real address, so a check that loads the live URL and looks for console errors will catch them before visitors do.

Run the free 30-second check on your live URL to spot console errors and broken page loads after you change domains.

Run the free 30-second check

← All posts

FlowCanary on SaaSHub