International internet outages: keeping your site and API up for users inside Iran
A domestic server is necessary but not sufficient. Your site probably depends on a handful of foreign domains you won't notice until outage day.
Founder & CTO, Parslinks
8pm, international connectivity is disrupted, and the support team is reading messages one by one: "The site opens but I can't log in." The server is inside Iran and monitoring is green. But the login form is waiting for Google's reCAPTCHA script, which never arrives, and the login button stays disabled until it does.
Many teams have been here. They moved the server home and relaxed, but the page still makes several requests to foreign domains from the user's browser. On a normal day those requests answer in milliseconds and nobody notices. On outage day, each one can hang for tens of seconds or never answer at all.
Find the hidden dependencies
The simplest method: open your key pages (home, product, cart, login, checkout) with the browser's developer tools, go to the Network tab and sort by domain. Every domain that isn't yours is a dependency.
To make this repeatable instead of a manual check, a small script can pull every external URL out of your build output:
Three groups, three approaches
Not every dependency is equal. Sort them into three groups.
Group one: remove
Things that come from abroad for no good reason and cost nothing to host locally:
- Fonts. Don't load your Persian font from Google Fonts; ship the file with the project. In Next.js,
next/font/localmakes this a few lines, and the font is served from your own domain. - JavaScript libraries from a CDN. Install jQuery or whatever arrives via a
scripttag from jsdelivr or unpkg through npm and bundle it. - Icons and images from external services.
Group two: replace with a local alternative
Things with an important job whose foreign version sits on the user's critical path:
- Captcha. If login or sign-up depends on reCAPTCHA, nobody can get in on outage day. Server-side rate limiting, a local captcha, or a simple anti-bot question is usually enough.
- Sign in with Google. If it's the only way in, users are locked out on outage day. Phone number plus one-time code is also more familiar to users in Iran.
- SMS and email providers. Sending login codes through a foreign provider means codes that never arrive during an outage.
Group three: make it non-critical
Things you need but that shouldn't block the user: analytics, error tracking like Sentry, live support chat. Load them async or after page load, so if they don't answer, the page doesn't wait.
Check the server side too
Dependencies aren't only in the browser. Your API may fetch an exchange rate from a foreign service on every order, or send confirmation emails through one. Two rules help:
Give every outbound request a timeout. Many libraries default to infinity or two minutes. Three to five seconds is enough for most things.
Push non-urgent work to a queue. Sending email, syncing with an external service and building reports don't need to happen inside the user's request. Queued, they run after the outage ends, and the user's order is already saved.
Rehearse before the real thing
The best test is a simulation. On a preview environment, block access to foreign domains (with firewall rules or a browser extension that blocks requests) and walk through the main paths: login, search, add to cart, checkout. Wherever you get stuck, you have a critical dependency.
Domestic payment gateways and local SMS providers shouldn't be affected by this test; if they are, something in that path still reaches abroad.
In short
A domestic server is half the job. The other half is making sure your pages and API don't depend on any foreign domain on the user's main path: local fonts and libraries, local login and captcha, and everything else async with a timeout.
Frequently asked questions
Join the discussion
- EY
ehsan yaghmori
Authorjsj
Related posts
- Guides
Moving from cPanel to Git-based deploys: a step-by-step guide for small teams
FTP uploads and editing files in cPanel's File Manager work for a small site, until two people change the same file at once. This guide walks through moving a PHP or Node.js site from cPanel to Git-based deploys, including the database, uploads, email and DNS.
- Platform
A Vercel alternative for teams in Iran: what it actually has to replace
Foreign-card payments, the risk of a suspended account and unreliable access to vercel.app push teams in Iran to look elsewhere. But renting a server and running next start covers only a small part of what Vercel did. Here is the full list, and how the alternatives compare.
- Deploy
Deploying Next.js to production: what SSG, ISR and SSR each need from your infrastructure
Each page's rendering mode decides what your server has to do. This post covers what SSG, ISR, SSR and PPR need from your infrastructure, how standalone output works, and what breaks once the app runs on more than one instance.
