Quantcast
Channel: 配列タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 757

環境変数で配列もハッシュも扱いたい

$
0
0

how

JSONにして、アプリケーション側でパースする
以上。

環境変数を入れる

bashで

$CORS_DOMAINS_JSON='["sample.com", "example.com"]'

docker-compose.ymlで

docker-compose.yml
environment:-CORS_DOMAINS_JSON=["sample.com", "example.com"]

環境変数をパースして使う

railsのrack-corsとか

config/application.json
config.middleware.insert_before0,Rack::CorsdoallowdooriginsJSON.parse(ENV.fetch('CORS_DOMAINS_JSON'){'[]'})resource"*",credentials: true,headers: :any,methods: [:get,:post,:options,:head,:patch,:delete]endend

その他各使用環境に合わせてjsonをパースするだけ


Viewing all articles
Browse latest Browse all 757

Trending Articles