Skip to content

Commit ce0c086

Browse files
committed
Added CORS documentation
1 parent f231b40 commit ce0c086

File tree

1 file changed

+18
-0
lines changed
  • src/content/docs/pipelines/sources

1 file changed

+18
-0
lines changed

src/content/docs/pipelines/sources/http.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,21 @@ curl https://<PIPELINE-ID>.pipelines.cloudflare.com
5959
{"key1": "value3", "key2": "value4"}
6060
]'
6161
```
62+
63+
## Specifying CORS Settings
64+
If you want to use your Pipeline to ingest client side data, such as website clicks, you'll need to configure your [Cross-Origin Resource Sharing (CORS) settings](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
65+
66+
Without setting your CORS settings, browsers will restrict requests made to your Pipeline endpoint. For example, if your website domain is `https://my-website.com`, and you want to post client side data to your pipeline at `https://<PIPELINE-ID>.pipelines.cloudflare.com`, without CORS settings, the request will fail.
67+
68+
To fix this, you need to configure your Pipeline to accept requests from `https://my-website.com`. You can do so while creating or updating a pipeline, using the flag `--cors-origins`. You can specify multiple domains separated by a comma and a space.
69+
70+
```sh
71+
$ npx wrangler pipelines update [PIPELINE-NAME] --cors-origins "https://mydomain.com", "http://localhost:8787"
72+
```
73+
74+
You can specify that all cross origin requests are accepted. We recommend only using this option for testing Pipelines, and not for production use cases.
75+
```sh
76+
$ npx wrangler pipelines update [PIPELINE-NAME] --cors-origins "*"
77+
```
78+
79+
After your the `--cors-origins` have been set on your Pipeline, your Pipeline will respond to preflight requests and POST requests with the appropriate `Access-Control-Allow-Origin` headers set.

0 commit comments

Comments
 (0)