mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Edit nginx/nginx.conf to enable CORS
This commit is contained in:
parent
f1353a3db9
commit
c7bc446ec8
@ -82,6 +82,22 @@ http {
|
|||||||
# max client request body size: average transaction size.
|
# max client request body size: average transaction size.
|
||||||
client_max_body_size 15k;
|
client_max_body_size 15k;
|
||||||
|
|
||||||
|
# GET requests are forwarded to BDB.
|
||||||
|
if ($request_method = GET) {
|
||||||
|
proxy_pass http://localhost:9984;
|
||||||
|
}
|
||||||
|
|
||||||
|
# POST requests: Enable CORS then forward to BDB.
|
||||||
|
if ($request_method = POST) {
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
|
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
|
|
||||||
|
proxy_pass http://localhost:9984;
|
||||||
|
}
|
||||||
|
|
||||||
|
# OPTIONS requests: Enable CORS and return 204.
|
||||||
if ($request_method = 'OPTIONS') {
|
if ($request_method = 'OPTIONS') {
|
||||||
add_header 'Access-Control-Allow-Origin' '*';
|
add_header 'Access-Control-Allow-Origin' '*';
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
@ -92,8 +108,6 @@ http {
|
|||||||
return 204;
|
return 204;
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_pass http://localhost:9984;
|
|
||||||
|
|
||||||
# Only return this response if request_method is neither POST|GET|OPTIONS
|
# Only return this response if request_method is neither POST|GET|OPTIONS
|
||||||
if ($request_method !~ ^(GET|OPTIONS|POST)$) {
|
if ($request_method !~ ^(GET|OPTIONS|POST)$) {
|
||||||
return 444;
|
return 444;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user