Skip to content

Commit 6a41513

Browse files
ben-hamelinstasadev
authored andcommitted
Update readme
1 parent 8c60941 commit 6a41513

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,38 @@ services:
7474
7575
You can use `ddev logs -s elasticsearch` to investigate the Elasticsearch daemon's activity or to troubleshoot RAM-related crashes.
7676

77+
### CORS settings
78+
79+
To better support decoupled architecture testing, HTTP.CORS configuration to expose the server to any origin is in place.
80+
81+
```yaml
82+
- "http.cors.allow-origin=*"
83+
- "http.cors.enabled=true"
84+
- "http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization,Access-Control-Allow-Origin,Access-Control-Request-Headers"
85+
- "http.cors.allow-credentials=true"
86+
- "http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE"
87+
```
88+
89+
When paired with a frontend request with the proper headers, this should allow for cross-origin requests.
90+
91+
```script
92+
// Example JS fetch() with headers
93+
fetch('http://vca.ddev.site:9200/elasticsearch_index_db/_search', {
94+
method: 'post',
95+
body: querystring,
96+
//headers: { 'Content-Type': 'application/json' },
97+
headers: {
98+
'Origin': 'http://localhost:8000',
99+
'Content-Type': 'application/json',
100+
'Access-Control-Allow-Origin': '*',
101+
'Access-Control-Request-Headers': 'access-control-allow-origin,content-type',
102+
},
103+
})
104+
```
105+
106+
107+
If you change this variable, make sure to remove the `#ddev-generated` line at the top of the file.
108+
77109
## Additional Resources
78110

79111
* There are two related answers to the [Stack Overflow question](https://stackoverflow.com/questions/54575785/how-can-i-use-an-elasticsearch-add-on-container-service-with-ddev) on ddev and Elasticsearch.

0 commit comments

Comments
 (0)