Force HTTPS and enable HSTS — Replit
HTTP is marked "Not Secure" by Chrome. Any HTTP request leaks cookies and lets attackers inject content on hostile networks. Missing HTTPS also caps SEO ranking.
Fixing this in Replit
Cloud IDE with Replit Agent
Replit Agent works best when you hand it a precise instruction and a scoped folder. Paste the prompt below into your Replit chat and the fix rolls out across the project in one pass.
Using a different tool? Pick your stack:
The prompt for Replit
Copy and paste this into your Replit chat exactly as-is.
In Replit, ask the Replit Agent to make these exact changes across the project: Force HTTPS 1. Configure your hosting provider to issue a Let's Encrypt certificate (most platforms do this automatically). 2. Add a permanent (301) redirect from http:// to https://. 3. Set the Strict-Transport-Security header so browsers refuse plain HTTP.
Why this matters
Google uses HTTPS as a ranking signal and Chrome labels HTTP sites "Not Secure" right in the address bar. No modern hosting platform charges for HTTPS — Vercel, Netlify, Replit, Lovable, Cloudflare all include free certificates.
HSTS takes HTTPS one step further: it tells the browser to refuse HTTP for your domain entirely, for a long max-age. This blocks an entire class of downgrade attacks.
Enabling HSTS also unlocks the HSTS preload list — Chrome and Firefox ship your domain as HTTPS-only out of the box, so even a first-time visitor on a compromised network is safe.
How to use this prompt in Replit
- 1. Open your Replit project.
- 2. Copy the prompt above with the copy button.
- 3. Paste into the Replit chat and send.
- 4. Review the diff, accept the changes, redeploy.
- 5. Verify the fix using the checklist below.
Common mistakes to avoid
- error_outlineEnabling HSTS before all subdomains serve HTTPS — browsers then refuse non-HTTPS subdomains.
- error_outlineSetting `Strict-Transport-Security: max-age=300` for "safety" — short max-age defeats the point.
- error_outlineRedirecting HTTP to HTTPS via a 302 instead of a 301 — SEO equity leaks.
- error_outlineRedirecting to a specific HTTPS path and losing the original query string.
How to verify the fix worked
- check_circleVisit `http://yoursite.com` — browser must redirect to HTTPS automatically.
- check_circle`curl -I http://yoursite.com` — returns `301 Moved Permanently` with an HTTPS Location header.
- check_circle`curl -I https://yoursite.com` — response includes `Strict-Transport-Security: max-age=31536000; includeSubDomains`.
- check_circleRun SSL Labs test at https://www.ssllabs.com/ssltest/ — grade A or A+.
Frequently asked questions
Do I need a paid SSL certificate?expand_more
Should I preload HSTS?expand_more
Can HSTS lock me out if something goes wrong?expand_more
Want all 34 prompts tailored to your Replit site?
Pantra scans your site in 10 seconds, detects the stack, and generates the exact prompts that apply — only the ones you actually need.
Scan my siteRelated Replit prompts
Add security headers (CSP, HSTS, X-Frame, etc.) — Replit
Stack-specific prompt to ship Content-Security-Policy, HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy in Lovable, Cursor, Bolt, v0, Replit, Windsurf, Claude Code, Base44.
SecurityMove API keys off the client bundle — Replit
Stack-specific prompt to move Supabase service keys, OpenAI keys, Stripe keys, and other secrets out of client code and into server env — for Lovable, Cursor, Bolt, v0, Replit, Windsurf, Claude Code, Base44.
SecurityEnable Supabase Row Level Security on every table — Replit
Prompt to enable RLS on every Supabase table and write sane policies — the #1 security fix for Lovable, Cursor, Bolt, v0, Replit, Windsurf, Claude Code, Base44 apps.