Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,38 @@ services:

You can use `ddev logs -s elasticsearch` to investigate the Elasticsearch daemon's activity or to troubleshoot RAM-related crashes.

### CORS settings

To better support decoupled architecture testing, HTTP.CORS configuration to expose the server to any origin is in place.

```yaml
- "http.cors.allow-origin=*"
- "http.cors.enabled=true"
- "http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization,Access-Control-Allow-Origin,Access-Control-Request-Headers"
- "http.cors.allow-credentials=true"
- "http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE"
```

When paired with a frontend request with the proper headers, this should allow for cross-origin requests.

```script
// Example JS fetch() with headers
fetch('http://vca.ddev.site:9200/elasticsearch_index_db/_search', {
method: 'post',
body: querystring,
//headers: { 'Content-Type': 'application/json' },
headers: {
'Origin': 'http://localhost:8000',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Request-Headers': 'access-control-allow-origin,content-type',
},
})
```


If you change this variable, make sure to remove the `#ddev-generated` line at the top of the file.

## Additional Resources

* 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.
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ services:
- VIRTUAL_HOST=${DDEV_HOSTNAME}
- HTTP_EXPOSE=9200:9200
- HTTPS_EXPOSE=9201:9200
- "http.cors.allow-origin=*"
- "http.cors.enabled=true"
- "http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization,Access-Control-Allow-Origin,Access-Control-Request-Headers"
- "http.cors.allow-credentials=true"
- "http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE"
Comment on lines +18 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these environment variables? Or some other type of configuration? Dots in environment variables are unusual. And who consumes this information?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: ${DDEV_APPROOT}
Expand Down
Loading