add CORS rules for allowing *.status.im domain calls

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-03-22 12:31:40 +01:00
parent 10d79744c7
commit 4773df2f1d
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
5 changed files with 16 additions and 0 deletions

View File

@ -5,3 +5,4 @@ faucet_account_pass: '{{lookup("passwordstore", "services/faucet/account-pass")}
faucet_account_addr: '{{lookup("passwordstore", "services/faucet/account-addr")}}'
faucet_account_json: '{{lookup("passwordstore", "services/faucet/account-json")}}'
faucet_domain: 'faucet-{{ stage }}.status.im'
faucet_cors_rule: '^https?://.*\.infura\.status.im'

View File

@ -11,6 +11,7 @@ faucet_account_json: '{"wallet":"json"}'
faucet_account_pass: 'very-secret-password'
faucet_network: 'rinkeby-faucet.example.org'
faucet_domain: 'rinkeby'
faucet_cors_rule: '.*'
```
# API

View File

@ -4,6 +4,7 @@ faucet_account_addr: ~
faucet_account_json: ~
faucet_domain: ~
faucet_network: ~
faucet_cors_rule: ~
faucet_cont_tag: 'fixed'
faucet_cont_image: 'statusteam/faucet:{{ faucet_cont_tag }}'

View File

@ -0,0 +1,10 @@
# This enables CORS for all status.im subdomains
if ($http_origin ~* '{{ faucet_cors_rule | mandatory }}') {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT';
add_header 'Access-Control-Allow-Headers' 'User-Agent,Keep-Alive,Content-Type';
add_header 'Access-Control-Allow-Credentials' 'true';
}
if ($request_method = OPTIONS) {
return 204;
}

View File

@ -14,5 +14,8 @@ server {
location / {
proxy_pass http://127.0.0.1:{{ faucet_http_port }}/;
{% include "cors-setup.conf.j2" %}
}
}