diff --git a/main/main.cpp b/main/main.cpp index 74a5699..2e3ec49 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -277,6 +277,8 @@ int main(int argc, char** argv) } svr.Get("/api/segments.json", [](const httplib::Request &, httplib::Response &res) { + res.set_header("Access-Control-Allow-Origin", "*"); + res.set_header("Access-Control-Allow-Methods", "GET"); json j; int i = 0; for (LedSegment* ledsegment : ledsegments) { @@ -293,6 +295,8 @@ int main(int argc, char** argv) }); svr.Put("/api/code.json", [](const httplib::Request &req, httplib::Response &res, const httplib::ContentReader &content_reader) { + res.set_header("Access-Control-Allow-Origin", "*"); + res.set_header("Access-Control-Allow-Methods", "PUT"); if (req.is_multipart_form_data()) { res.set_content("No multipart forms allowed", "text/plain"); return true; @@ -316,6 +320,12 @@ int main(int argc, char** argv) return true; }); + svr.Options("/api/code.json", [](const httplib::Request &req, httplib::Response &res) { + res.set_header("Access-Control-Allow-Origin", "*"); + res.set_header("Access-Control-Allow-Methods", "PUT"); + return true; + }); + std::thread httpserverthread(starthttpserver); ws2811_return_t ret; @@ -336,4 +346,4 @@ int main(int argc, char** argv) ws2811_render(&ledstring); std::this_thread::sleep_for(std::chrono::milliseconds(frametime)); } -} \ No newline at end of file +}