# CORS responses cached for the wrong origin (missing Vary: Origin)

**Code:** `Vary: Origin` · **Category:** HTTP · **Seen on:** HTTP, Browser, Cloudflare

A cache or CDN stored a CORS response for one origin and served it to another, so some sites get blocked.

## Meaning

When `Access-Control-Allow-Origin` is reflected per request, responses differ by `Origin`. Without `Vary: Origin`, a CDN or browser cache can return the header for a different site, causing random CORS failures. Add `Vary: Origin`.

## Common causes

- Dynamic Allow-Origin without `Vary: Origin`
- CDN caching responses by URL only
- Browser cache reusing a response across origins
- Multiple front-ends using one API
- Header overwritten by the proxy

## Quick fix

1. Add `Vary: Origin` whenever Allow-Origin is dynamic
2. Include Origin in the CDN cache key (or bypass cache)
3. Purge cached CORS responses

## Detailed fix by platform

### Express

1. `res.set("Vary", "Origin");`

## How to diagnose

1. **Allow-Origin** — Dynamic?
2. **Vary** — Origin set?
3. **CDN key** — Includes Origin?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/http/cors-vary-origin-missing)
