diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-14 10:05:59 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-14 10:05:59 +0200 |
| commit | c9077bd7494ee4d6f085d4637b8b0a49b1591858 (patch) | |
| tree | d9cad48adcd3db9a0779ba2c114863691a7bc33e | |
| parent | 0853cd491deac3b606e4eeadd9c340b57227ebba (diff) | |
| download | ffwd-c9077bd7494ee4d6f085d4637b8b0a49b1591858.tar.gz ffwd-c9077bd7494ee4d6f085d4637b8b0a49b1591858.zip | |
server: remove CORS support
| -rw-r--r-- | embed_server.c | 12 | ||||
| -rw-r--r-- | embed_server.h | 1 | ||||
| -rw-r--r-- | tests/test_cli.c | 6 | ||||
| -rw-r--r-- | tests/test_server.c | 2 |
4 files changed, 5 insertions, 16 deletions
diff --git a/embed_server.c b/embed_server.c index a3317c0..b34cecd 100644 --- a/embed_server.c +++ b/embed_server.c @@ -279,7 +279,6 @@ typedef struct { int batch_size; int max_batch_tokens; int batch_wait_us; - int enable_cors; char *api_key; loaded_model models[MODEL_COUNT]; int use_mlx; @@ -466,11 +465,7 @@ static void append_http_response_ex(client *c, int status, const char *ctype, c->close_after_write ? "close" : "keep-alive"); if (ctype) sbuf_printf(&c->out, "Content-Type: %s\r\n", ctype); - if (c->srv->enable_cors) { - sbuf_puts(&c->out, "Access-Control-Allow-Origin: *\r\n"); - sbuf_puts(&c->out, "Access-Control-Allow-Headers: authorization, content-type\r\n"); - sbuf_puts(&c->out, "Access-Control-Allow-Methods: POST, OPTIONS\r\n"); - } + if (extra_headers) sbuf_puts(&c->out, extra_headers); sbuf_puts(&c->out, "\r\n"); @@ -2914,7 +2909,6 @@ int embed_run_server(const embed_server_config_t *cfg) { ? cfg->batch_wait_us : (cfg->use_cuda ? EMBED_SERVER_CUDA_BATCH_WAIT_US : EMBED_SERVER_BATCH_WAIT_US); - s.enable_cors = cfg->enable_cors; s.use_mlx = cfg->use_mlx; s.use_cuda = cfg->use_cuda; s.mlx_quantize_bits = cfg->mlx_quantize_bits; @@ -3057,7 +3051,6 @@ static void print_usage(const char *prog) " --host HOST Bind host (default: 127.0.0.1)\n" " --port N Bind port (default: 8000)\n" " --api-key K Require Authorization: Bearer K\n" - " --cors Enable CORS headers\n" " -b, --batch-size N Max texts or documents per inference batch\n" " (default: 32)\n" " --max-batch-tokens N Max tokens per inference batch (default: 16384)\n" @@ -3145,7 +3138,6 @@ int main(int argc, char *argv[]) const char *host = "127.0.0.1"; const char *api_key = NULL; int port = 8000; - int cors = 0; model_specs_t model_specs = {0}; int arg = 1; @@ -3180,7 +3172,6 @@ int main(int argc, char *argv[]) else if (!strcmp(f, "--host")) { host = argv[++arg]; } else if (!strcmp(f, "--port")) { port = atoi(argv[++arg]); } else if (!strcmp(f, "--api-key")) { api_key = argv[++arg]; } - else if (!strcmp(f, "--cors")) { cors = 1; } else if (!strcmp(f, "-b") || !strcmp(f, "--batch-size")) { batch_size = atoi(argv[++arg]); } @@ -3333,7 +3324,6 @@ int main(int argc, char *argv[]) .mlx_quantize_bits = mlx_quantize_bits, .mlx_quantize_group_size = mlx_quantize_group_size, .memory_utilization = memory_utilization, - .enable_cors = cors, .api_key = api_key, }; int rc = embed_run_server(&scfg); diff --git a/embed_server.h b/embed_server.h index 80c9aca..c10dddb 100644 --- a/embed_server.h +++ b/embed_server.h @@ -34,7 +34,6 @@ typedef struct { double memory_utilization; /* fraction of physical memory the MLX preflight may plan for; 0 = default 0.90, values above 1.0 allow overcommit */ - int enable_cors; const char *api_key; } embed_server_config_t; diff --git a/tests/test_cli.c b/tests/test_cli.c index a6a065c..c5151e9 100644 --- a/tests/test_cli.c +++ b/tests/test_cli.c @@ -117,10 +117,10 @@ int main(int argc, char **argv) expect(run_cli(args, NULL) == 0, "single text exits 0"); expect(stdout_is_embedding(dims.hidden), "single text prints dim floats"); - /* Explicit CPU backend and thread count. */ + /* Thread count. */ snprintf(args, sizeof(args), - "-d '%s' --backend cpu -t 2 -v 'hello world'", g_dir); - expect(run_cli(args, NULL) == 0, "--backend cpu -t 2 -v exits 0"); + "-d '%s' -t 2 -v 'hello world'", g_dir); + expect(run_cli(args, NULL) == 0, "-t 2 -v exits 0"); expect(file_contains(g_err, "Using 2 CPU thread(s)"), "-v reports the thread count"); diff --git a/tests/test_server.c b/tests/test_server.c index 2e99881..113b4d7 100644 --- a/tests/test_server.c +++ b/tests/test_server.c @@ -320,7 +320,7 @@ static void test_http_embeddings(int port) { char *body = NULL; - /* CORS preflight and routing. */ + /* Routing. */ TEST_ASSERT(http_req(port, "OPTIONS", "/v1/embeddings", NULL, NULL, NULL, NULL) == 204); TEST_ASSERT(http_req(port, "GET", "/v1/embeddings", TEST_API_KEY, NULL, |
