summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-01-05 16:39:07 +0100
committerDaniel Weipert <code@drogueronin.de>2022-01-10 11:29:13 +0100
commit47e6d88484eba2733551de9edde8c4ac58706e5e (patch)
tree1ca32046be32e67c795127e09e951aea92861200
parent39c0f9b8346447b27d65da1d62f8e03697fe8907 (diff)
Add CORS header
-rw-r--r--src/App.php1
-rw-r--r--templates/config/config.toml3
2 files changed, 4 insertions, 0 deletions
diff --git a/src/App.php b/src/App.php
index b270b02..107113a 100644
--- a/src/App.php
+++ b/src/App.php
@@ -106,6 +106,7 @@ class App
}
$response->headers->set('Content-Type', 'application/json');
+ $response->headers->set('Access-Control-Allow-Origin', implode(',', $config['api']['cors']['origins']));
$response->setContent(json_encode($content));
$response->send();
}
diff --git a/templates/config/config.toml b/templates/config/config.toml
index 1011e90..8f9a76f 100644
--- a/templates/config/config.toml
+++ b/templates/config/config.toml
@@ -9,3 +9,6 @@ password = 123456
[api]
keys = []
+[api.cors]
+origins = []
+