> For the complete documentation index, see [llms.txt](https://motivlabs.gitbook.io/janus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://motivlabs.gitbook.io/janus/plugins/cors.md).

# CORS

Easily add Cross-origin resource sharing (CORS) to your API by enabling this plugin.

## Configuration

The plain cors config:

```javascript
"cors": {
    "enabled": true,
    "config": {
        "domains": ["*"],
        "methods": ["GET", "POST"],
        "request_headers": ["X-Custom-Header", "X-Foobar"],
        "exposed_headers": ["X-Something-Special"],
        "options_passthrough": true
    }
}
```

| Configuration        | Description                                                                                                                                                                   |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| domains              | A comma-separated list of allowed domains for the Access-Control-Allow-Origin header. If you wish to allow all origins, add \* as a single value to this configuration field. |
| methods              | Value for the Access-Control-Allow-Methods header, expects a comma delimited string (e.g. GET,POST).                                                                          |
| request\_headers     | Value for the Access-Control-Allow-Headers header, expects a comma delimited string (e.g. Origin, Authorization).                                                             |
| exposed\_headers     | Value for the Access-Control-Expose-Headers header, expects a comma delimited string (e.g. Origin, Authorization). If not specified, no custom headers are exposed.           |
| options\_passthrough | Instructs preflight to let other potential next handlers to process the OPTIONS method.                                                                                       |
