Elastic社のElastic Cloudで、Elasticsearchサーバーに対してCORSを設定する
4170 ワード
Elasticsearchで試していると、ひとまず手取り早く試したいという時がくると思います。
その時のメモです。
Elastic社のElastic Cloudに作成したElasticsearchに対して、直接クエリを投げるWebアプリを(テスト的に)作った際に、デフォルトの設定のままではCORSの制限に引っかかります。
以下ドキュメントから
Add Elasticsearch user settings | Elasticsearch Service Documentation | Elastic
1. Log in to the Elasticsearch Service Console.
2. Select your deployment on the home page in the Elasticsearch Service card or go to the deployments page.
3. From your deployment menu, go to the Edit page.
4. At the bottom of each Elasticsearch node, expand the User settings overrides caret.
5. Update the user settings.
開いたエディタ部分にHTTPの設定を入れる
http:
cors.enabled: true
cors.allow-origin: /https?:\/\/(localhost(:[0-9]+)?|xxxxx.github.io)/
cors.allow-methods: GET
cors.allow-headers: Authorization, X-Requested-With,X-Auth-Token,Content-Type, Content-Length
※以下の2つからのアクセスを許可する設定にしています。
- localhost
- xxxxx.github.io
6. Click Save changes.
Saveボタンを押すとサーバーの更新が始まります。
ローディングが終わったら設定が反映されています。
コンソールログにもエラーは出なくなりました。
参考
Add Elasticsearch user settings | Elasticsearch Service Documentation | Elastic
Author And Source
この問題について(Elastic社のElastic Cloudで、Elasticsearchサーバーに対してCORSを設定する), 我々は、より多くの情報をここで見つけました https://qiita.com/sugasaki/items/6440621749fd2c8017c2著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .