mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-24 15:48:58 +01:00
server : allow CORS request with authorization headers (#1850)
Whisper plugin in Obsidian requires an API key which is then sent as an authorization header. However, the presence of an authorization header requires a CORS Preflight, so both the OPTIONS method and the Access-Control-Allow-Headers: authorization must be handled.
This commit is contained in:
parent
19f8048139
commit
80e8a2ea39
@ -541,7 +541,7 @@ int main(int argc, char ** argv) {
|
||||
Server svr;
|
||||
svr.set_default_headers({{"Server", "whisper.cpp"},
|
||||
{"Access-Control-Allow-Origin", "*"},
|
||||
{"Access-Control-Allow-Headers", "content-type"}});
|
||||
{"Access-Control-Allow-Headers", "content-type, authorization"}});
|
||||
|
||||
std::string const default_content = R"(
|
||||
<html>
|
||||
@ -623,6 +623,9 @@ int main(int argc, char ** argv) {
|
||||
return false;
|
||||
});
|
||||
|
||||
svr.Options(sparams.request_path + "/inference", [&](const Request &req, Response &res){
|
||||
});
|
||||
|
||||
svr.Post(sparams.request_path + "/inference", [&](const Request &req, Response &res){
|
||||
// acquire whisper model mutex lock
|
||||
std::lock_guard<std::mutex> lock(whisper_mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user