CORS — cross-origin resource sharing
This section uses a single On/Off switch at the top to turn CORS on or off for the domain. Off deletes the domain's entire CORS configuration (all rules).
CORS (Cross-Origin Resource Sharing) lets the edge generate the Access-Control-Allow-* headers itself, so that browsers on a website with a different origin are allowed to call your domain's resources, instead of leaving this to your origin. Each domain has a list of rules matched by path and hostname that define which origins, methods and headers are allowed. The edge also answers preflight requests (OPTIONS) with 204 without going to the origin.
Use it when your API, fonts or images are called from another website (a frontend on a different domain) through the browser. Example: a React app at https://app.example.net needs to call the API at https://api.example.com. Add one CORS rule that allows the origin https://app.example.net.
Before you start
- The domain has been added and points to VNIS.
- You know the exact origin(s) allowed to make calls (in the form
https://domain-name).
How to configure
This section uses a single On/Off switch at the top: On creates and applies the CORS configuration (saved immediately); Off deletes all CORS rules for the domain. Rules are shown even when the switch is Off, so you can add or edit them first and then switch On.
- Go to Domains → select a domain → CORS tab.

- Click Add Rule. Set Path Pattern and Match Type, enter Allowed Origins (at least 1), choose Allowed Methods, and optionally set Allowed/Expose Headers, Allow Credentials and Max-Age.
- Turn the switch On at the top of the section. For later edits, click Save (shown only when the switch is On and there are unsaved changes).
Configuration fields
Section level:
| Field | Meaning | Values | Default | Notes |
|---|---|---|---|---|
| On/Off switch (section corner) | Turns CORS on or off for the domain — On creates, Off deletes | Switch | Off (not configured) | Off means no CORS headers are added, OPTIONS requests are not short-circuited, and the configuration is deleted (you must configure it again to turn it back on). You cannot switch On while a rule has errors |
| Rules | List of rules | ≤ 50 rules | — | The first matching rule by priority is applied (first-match) |
Each rule:
| Field | Meaning | Values | Default | Notes |
|---|---|---|---|---|
| Priority | Order in which rules are evaluated | Integer ≥ 0, must be unique | 0 (the UI sets it to max+1) | Lower numbers are evaluated first (ascending order). Two rules with the same priority → 400 |
| Path Pattern | Path pattern the rule applies to | String, not empty, ≤500 characters (bytes) for every Match Type | /* | Regex must be valid. Over 500 → 400 |
| Match Type | How the path is compared | exact / prefix / regex | prefix | — |
| Match Hostnames | Restrict by hostname (OR) | ≤20 | Empty (= all hosts) | Operators equals/contains/starts_with/ends_with/wildcard/regex |
| Allow Origins | Allowed origins | ≥1 (up to 100); * = any origin | — | Empty → 400 |
| Allow Methods | Allowed methods (sent only in the preflight response) | Subset of GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS | GET,HEAD,OPTIONS | Unknown method → 400 |
| Allow Headers | Headers the client may send (preflight) | List | — | Joined into Access-Control-Allow-Headers |
| Expose Headers | Headers the client may read (actual response) | List | — | — |
| Allow Credentials | Allow cookies/credentials to be sent | On/off | Off | Cannot be turned on together with * in Allow Origins → 400 |
| Max-Age | How long the preflight response is cached | Seconds, ≤ 86400 | 86400 | > 86400 → 400 |
Configuration examples
Rules are evaluated by priority (lower numbers first), and evaluation stops at the first rule that matches the path and hostname.
Example 1 — Allow a specific frontend to call the entire API.
- Path Pattern
/*(prefix) · Allow Origins[https://app.example.net]· Allow MethodsGET,POST,OPTIONS· Max-Age600 - Result: requests with
Origin: https://app.example.netreceiveAccess-Control-Allow-Origin: https://app.example.net+Vary: Origin; theOPTIONSpreflight receives204+Access-Control-Allow-Methods: GET, POST, OPTIONS. - Check:
curl -I -H "Origin: https://app.example.net" https://api.example.com/→ theAccess-Control-Allow-Originheader is present.
Example 2 — Public resources for any origin (images/fonts, no credentials).
- Path Pattern
/assets/(prefix) · Allow Origins[*]· Allow Credentialsoff· Allow MethodsGET,HEAD,OPTIONS - Result:
/assets/*returnsAccess-Control-Allow-Origin: *for every origin. - Because
*is used, you cannot turn on Allow Credentials. - Check:
curl -I -H "Origin: https://any-site.example" https://example.com/assets/logo.png.
Example 3 — An API that needs to send cookies (credentials) from one explicitly named origin.
- Path Pattern
/api/(prefix) · Allow Origins[https://portal.example.com]· Allow Credentialson· Allow MethodsGET,POST,PUT,OPTIONS - Result: the edge reflects exactly that origin (not
*) +Access-Control-Allow-Credentials: true+Vary: Origin. - Check: send a request with cookies and the correct
Origin→ you receive both headers; a different origin → no headers.
Order of evaluation
- The On/Off switch controls whether the configuration exists: On creates the CORS record; Off deletes all CORS rules for the domain.
- First-match by priority (lower numbers first). If two rules both match the path and hostname, the rule with the lower priority wins.
- If a rule matches the path but the request's origin is not in Allow Origins, the edge adds no headers (safe by default).
- Preflight
OPTIONSrequests with anOriginheader are answered by the edge with204without going to the origin. - When Allow Credentials is on, the edge never uses
*; it always reflects the specific origin and addsVary: Origin. - If the combination
credentials + "*"exists (for example, from imported data), the edge drops all CORS headers (fail-closed) to stay safe.
Troubleshooting
| Symptom | Common cause | Fix |
|---|---|---|
| Cannot turn the switch On (greyed out) | A rule has errors (missing origin / unknown method / Max-Age / credentials+*) | Fix all errors, then try again |
| Saving returns 400 "allow_credentials cannot be used with wildcard" | Allow Credentials is on together with * | List specific origins instead of *, or turn off credentials |
| Saving returns 400 "at least one origin is required" | Allow Origins is empty | Add at least 1 origin |
| Saving returns 400 "invalid method" | Unknown method (for example TRACE) | Use only valid methods |
| Saving returns 400 on Max-Age | > 86400 | Reduce to ≤ 86400 |
| The browser still reports a CORS error | The request origin does not match Allow Origins, or another rule with a lower priority takes precedence | Check the exact origin and the priority order |
| Credentials are not sent | * is used (not valid with credentials) | List specific origins and turn on Allow Credentials |
FAQ
- Can I use
*? Yes, for public resources without credentials. If you need to send cookies/credentials, you must list specific origins. - Do preflight
OPTIONSrequests go to the origin? No. The edge answers with204itself when CORS is on and the request has anOriginheader. - Why is there a
Vary: Originheader? When the edge reflects a specific origin, it addsVary: Originso the cache keeps separate entries per origin. - Where do Allow Methods/Headers appear? Only in the preflight response. Expose Headers appear in the actual response.