Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #89 from ender503/cors-request
Browse files Browse the repository at this point in the history
fix: add response header to allow CORS requests
  • Loading branch information
Wu Yu Wei authored Mar 6, 2019
2 parents 8553021 + 968f59a commit 7cb1187
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions accelerator/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ int main(int, char const**) {
api_find_transactions_by_tag(&service, req.params["tag"].c_str(),
&json_result);
res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json_result;
});

Expand All @@ -65,6 +66,7 @@ int main(int, char const**) {
api_get_transaction_object(&service, req.params["tx"].c_str(),
&json_result);
res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json_result;
});

Expand All @@ -86,6 +88,7 @@ int main(int, char const**) {
api_find_transactions_obj_by_tag(&service, req.params["tag"].c_str(),
&json_result);
res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json_result;
});

Expand All @@ -104,6 +107,7 @@ int main(int, char const**) {

api_get_tips_pair(&service, &json_result);
res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json_result;
});

Expand All @@ -122,6 +126,7 @@ int main(int, char const**) {

api_get_tips(&service, &json_result);
res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json_result;
});

Expand All @@ -140,6 +145,7 @@ int main(int, char const**) {

api_generate_address(&service, &json_result);
res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json_result;
});

Expand Down Expand Up @@ -170,6 +176,7 @@ int main(int, char const**) {
}

res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json_result;
});

Expand All @@ -191,6 +198,7 @@ int main(int, char const**) {

res.set_status(SC_BAD_REQUEST);
res.set_header("Content-Type", "application/json");
res.set_header("Access-Control-Allow-Origin", "*");
res << json;

cJSON_Delete(json_obj);
Expand Down

0 comments on commit 7cb1187

Please sign in to comment.