mitigatin CORS problems on api endpoint

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-01-06 00:09:30 +01:00
parent 9fd1a62b72
commit a802cbaf9c

View File

@@ -94,6 +94,7 @@ public class ApiEndpoint extends PathHandler {
String hostname = hostname(ex);
String urlTemplate = hostname+"/static/event?id={}";
String prodId = "OpenCloudCal@"+hostname.split("://",2)[1];
ex.getResponseHeaders().add("Access-Control-Allow-Origin","*");
return switch (path) {
case "/event" -> sendContent(ex,getEvent(ex).map(ApiEndpoint::toJson).map(ApiEndpoint::httpError));
case "/event/ical"-> sendContent(ex,getEvent(ex).map(event -> toIcal(event, hostname, urlTemplate)).map(ical -> Util.wrapIcal(ical,prodId)).map(ApiEndpoint::httpError));