Skip to content

Commit 797155a

Browse files
authored
Merge pull request ggml-org#10 from cirk2/master
Add Options enpoints and Access-Control-Allow-Headers to satisfy CORS
2 parents f7882e2 + 5bbc030 commit 797155a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/server/server.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,10 @@ int main(int argc, char **argv)
719719

720720
Server svr;
721721

722-
svr.set_default_headers({ {"Access-Control-Allow-Origin", "*"} });
722+
svr.set_default_headers({
723+
{"Access-Control-Allow-Origin", "*"},
724+
{"Access-Control-Allow-Headers", "content-type"}
725+
});
723726

724727
svr.Get("/", [](const Request &, Response &res)
725728
{ res.set_content("<h1>llama.cpp server works</h1>", "text/html"); });
@@ -874,6 +877,11 @@ int main(int argc, char **argv)
874877
}
875878
});
876879

880+
svr.Options(R"(/.*)", [&llama](const Request &req, Response &res)
881+
{
882+
return res.set_content("", "application/json");
883+
});
884+
877885
svr.Post("/tokenize", [&llama](const Request &req, Response &res)
878886
{
879887
json body = json::parse(req.body);

0 commit comments

Comments
 (0)