From b21044fe42b970b7cea74be674c38637ee28bf78 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 17 May 2016 20:42:35 +0200 Subject: [PATCH 1/2] Add CORS headers to Read Only Gateway Default config License: MIT Signed-off-by: Jakub Sztandera --- repo/config/init.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/repo/config/init.go b/repo/config/init.go index f8f4a4890..35ccda36b 100644 --- a/repo/config/init.go +++ b/repo/config/init.go @@ -62,6 +62,11 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { RootRedirect: "", Writable: false, PathPrefixes: []string{}, + HTTPHeaders: map[string][]string{ + "Access-Control-Allow-Origin": []string{"*"}, + "Access-Control-Allow-Methods": []string{"GET"}, + "Access-Control-Allow-Headers": []string{"X-Requested-With"}, + }, }, } From c0393383fdcd57d074ac3e13e76ecc4f7c4ca72d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 1 Jun 2016 19:05:43 +0200 Subject: [PATCH 2/2] test: CORS is enabled by default License: MIT Signed-off-by: Jakub Sztandera --- test/sharness/t0112-gateway-cors.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/sharness/t0112-gateway-cors.sh b/test/sharness/t0112-gateway-cors.sh index 1cc9371c4..dbb51021a 100755 --- a/test/sharness/t0112-gateway-cors.sh +++ b/test/sharness/t0112-gateway-cors.sh @@ -7,10 +7,6 @@ test_description="Test HTTP Gateway CORS Support" test_config_ipfs_cors_headers() { - ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Origin '["*"]' - ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]' - ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]' - ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST"]' ipfs config --json API.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]'