AIcv

← Blog

Why an AI app needs a relay — and how to run your own

· Updated · AIcv Team · Tags: #privacy #architecture #relay #open-source

AIcv has no application backend. Your CV, the job description, your API key and your application records live in your browser, and generation requests go from your browser to the AI provider you chose. That works for most providers, but not all of them — and the reason is a browser rule called CORS.

This page explains why the relay exists, what it does with your data, and how to remove it from the loop if you would rather run your own.

The short version

  • OpenRouter, Gemini, xAI and DeepSeek allow browser requests. AIcv calls them directly. No relay.
  • OpenAI and Anthropic refuse browser requests. AIcv forwards those calls through a small relay at /api/proxy on this site.
  • The relay logs nothing and stores nothing. It checks the destination against a fixed allowlist, forwards the request, streams the answer back, and forgets it.
  • You can self-host the relay (the code is in the repo) and point Settings at your own URL. You can also use a direct provider and never touch it.

What CORS actually blocks

When a page on aicv-web.pages.dev calls api.openai.com, the browser first sends a small permission request — a preflight — asking the provider whether this origin is allowed to call it.

Most AI providers answer yes, usually with a wildcard that allows any website. OpenAI and Anthropic answer no. They are designed for server-side code, where there is no browser and no origin to check.

The block happens in your browser, before the request is sent. No key is transmitted, and no error comes back from the provider. The browser simply refuses. You cannot fix it with a header, a different fetch call, or a clever workaround — the only options are:

1. Do not call that provider from the browser.

2. Put a small server in between that the browser is allowed to call.

AIcv uses option 1 wherever possible and option 2 only where it is not.

What the relay does

The relay is one Cloudflare Pages Function (the same code also ships as a standalone Worker). For each request it:

  • reads the intended provider URL from a header, and rejects anything not on the allowlist — the bundled AI providers only;
  • only allows chat, completion, model-listing and embedding paths, so it cannot be used as a general-purpose open proxy;
  • forwards the request body and the provider's auth header (Authorization for OpenAI, x-api-key for Anthropic) to that host;
  • streams the provider's response straight back to your browser;
  • writes nothing: no request log, no response log, no database, no analytics;
  • rejects cross-site calls, so another website cannot borrow it;
  • applies an in-memory per-IP rate limit to stop abuse.

Your API key goes to the provider you selected. It is not stored by the relay, and it is not sent anywhere else.

The honest trade-off

A relay is still a hop. When you pick OpenAI or Anthropic, the text of your prompt — including the parts of your CV and the job description you are tailoring to — passes through a server we operate, even though that server keeps no copy.

If that is not acceptable for you, you have three alternatives:

  • Use a direct provider. OpenRouter, Gemini, xAI and DeepSeek never touch the relay.
  • Run your own relay. Deploy the Worker from packages/worker, set ALLOWED_ORIGINS to your AIcv origin, and paste its URL into Settings → CORS relay URL. Requests then go browser → your worker → provider, and we are not involved at all.
  • Clear the relay field. AIcv will call the provider directly. This only works for providers that allow browser requests; OpenAI and Anthropic will fail with a CORS error.

A relay only fixes the browser's CORS check. It does not change the region the request comes from: if the provider blocks Hong Kong, a relay running in Hong Kong is still blocked. What the 403 means.

The full data-flow description, including what Cloudflare sees as a host, is in the privacy policy.

Pointing AIcv at your own relay

1. Clone the repository and open packages/worker.

2. Deploy it with Wrangler. Wrangler puts the Worker on your account's workers.dev subdomain. Pick a neutral Worker name, or attach a custom domain, if you do not want your account name in the URL you share.

3. Set ALLOWED_ORIGINS to the origin you use AIcv from. If you use a custom endpoint on your own domain, add that host to EXTRA_TARGET_HOSTS as well.

4. In AIcv, open Settings and expand the relay field under the provider you selected.

5. Paste your Worker URL. It is used for every provider from then on, and a Reset link puts the built-in relay back.

Self-hosting is also the honest answer for anyone who wants to verify the "no logging" claim instead of trusting it. The relay is small, and the code is the same file that runs here.

Frequently asked questions

Does the relay see my API key?

The relay forwards the provider's auth header to the chosen host. It does not log or store the key, the prompt or the response, and the code is in the same repository. You can self-host it if you would rather not trust the hosted copy.

Which providers use the relay?

OpenAI and Anthropic in the web app, because those APIs block direct browser requests. OpenRouter, Gemini, xAI, DeepSeek and custom endpoints are called directly from the browser.

Can the relay bypass a region block?

No. The relay fixes the browser's CORS check, not geography. If OpenAI or Anthropic blocks Hong Kong, a relay running in Hong Kong is still blocked. What the 403 means.

Can I remove the relay entirely?

Yes. Use a direct provider, or deploy the Worker yourself and point Settings at your own relay URL. OpenAI and Anthropic will still fail if you call them directly from the browser, because their CORS policy has not changed.

Related reading