diff --git a/source/app.d b/source/app.d index 981ad27a..477a1c49 100644 --- a/source/app.d +++ b/source/app.d @@ -166,7 +166,15 @@ shared static this() auto urlRouter = new URLRouter; auto fsettings = new HTTPFileServerSettings; fsettings.serverPathPrefix = "/static"; + + void sendOptions(HTTPServerRequest req, HTTPServerResponse res) + { + import std.algorithm.comparison : among; + if (req.host.among("tour.dlang.org", "tour.dlangg.io", "dlang.org", "dtest.dlang.io", "127.0.0.1", "localhost")) + res.headers["Access-Control-Allow-Origin"] = "*"; + } urlRouter + .any("/api/*", &sendOptions) .registerWebInterface(new WebInterface(contentProvider, config.googleAnalyticsId, defaultLang)) .registerRestInterface(new ApiV1(execProvider, contentProvider)) .get("/static/*", serveStaticFiles(publicDir.buildPath("static"), fsettings));