logo
Parslinks
Back to blog
Guides6 min read

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.

Ehsan Yaghmori

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.

Table of hidden external dependencies in a site and a local alternative for each

To make this repeatable instead of a manual check, a small script can pull every external URL out of your build output:

terminal
# Every domain referenced in the built HTML and JS
grep -rhoE 'https?://[a-zA-Z0-9.-]+' .next/static .next/server/app \
  | sort | uniq -c | sort -rn | head -30
bash3 lines

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/local makes 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 script tag from jsdelivr or unpkg through npm and bundle it.
  • Icons and images from external services.
app/fonts.ts
import localFont from "next/font/local";

// Served from your own domain, not a foreign one
export const vazir = localFont({
  src: [
    { path: "./fonts/Vazirmatn-Regular.woff2", weight: "400" },
    { path: "./fonts/Vazirmatn-Bold.woff2", weight: "700" },
  ],
  display: "swap",
  variable: "--font-vazir",
});
ts11 lines

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.

lib/rates.ts
// Outbound call with a deadline; its failure must not break the order
async function fetchRate(): Promise<number | null> {
  try {
    const res = await fetch("https://rates.example.com/usd", {
      signal: AbortSignal.timeout(4000),
    });
    if (!res.ok) return null;
    return (await res.json()).rate;
  } catch {
    return null; // fall back to the last stored rate
  }
}
ts12 lines

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

    Author

    jsj