> For the complete documentation index, see [llms.txt](https://docs.weka.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.weka.io/security/manage-cross-origin-resource-sharing.md).

# Manage Cross-Origin Resource Sharing

Manage trusted sites for Cross-Origin Resource Sharing using CLI commands.

Cross-Origin Resource Sharing (CORS) is a security mechanism implemented by web browsers that restricts how a web page from one domain can request resources from a different domain. This essentially defines the rules for communication between a web application and the server that hosts the resources it needs.

**Why do we need CORS?**

Imagine a scenario where a website (yourbank.com) relies on functionalities from another website (images.com) to display product images. If browsers didn't have CORS, images.com could potentially steal your login credentials from yourbank.com through a malicious script.

CORS prevents such unauthorized access by enforcing a set of rules. The server hosting the resources (images.com) can specify which websites (origins) can access them through special HTTP headers. This ensures that your sensitive data on yourbank.com remains secure.

In summary, CORS helps maintain web security by:

* **Preventing unauthorized access:** It restricts malicious websites from accessing resources on other domains.
* **Enforcing communication protocols:** It defines a clear communication channel between browsers and servers for cross-origin requests.

## **CORS CLI commands**

### List the CORS trusted sites

Lists the origins allowed to make cross-origin requests to the cluster's API.

**Command:** `weka security cors-trusted-sites list`

```sh
weka security cors-trusted-sites list
```

### Add a CORS trusted site

Adds an origin to the CORS trusted list.

**Command:** `weka security cors-trusted-sites add`

```sh
weka security cors-trusted-sites add <site>
```

**Parameters**

| Parameter | Description                                      |
| --------- | ------------------------------------------------ |
| `site`\*  | Site to trust for cross origin resource sharing. |

Example:

```
$ weka security cors-trusted-sites add http://site_3.com
```

### Remove a CORS trusted site

Removes a single origin from the CORS trusted list.

**Command:** `weka security cors-trusted-sites remove`

```sh
weka security cors-trusted-sites remove <site>
```

**Parameters**

| Parameter | Description                           |
| --------- | ------------------------------------- |
| `site`\*  | Site to remove from the trusted list. |

### Remove all trusted sites from the CORS list

Clears the CORS trusted list, disallowing all cross-origin requests.

**Command:** `weka security cors-trusted-sites reset`

```sh
weka security cors-trusted-sites reset
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.weka.io/security/manage-cross-origin-resource-sharing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
