Skip to main content

How to Let a Web App Call an MLflow Server with --cors-allowed-origins

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

A web page can only call an API on another address when that API agrees, and an MLflow tracking server agrees only to pages served from localhost or 127.0.0.1. Your own web app on any other address gets 403 Forbidden and Cross-origin request blocked. --cors-allowed-origins adds it. This guide allows an app at http://app.localhost:3000, with real output from MLflow 3.18.0.

Syntax​

Syntax
mlflow server --cors-allowed-origins "<origin>,<origin>,..."
PartWhat it means
<origin>Where a web page comes from: its scheme, name and port, such as http://app.localhost:3000, with no path and no slash at the end
,Separates the origins

MLflow's CLI reference: "Comma-separated list of allowed CORS origins to prevent cross-site request attacks (default: localhost origins on any port). CORS attacks allow malicious websites to make requests to your MLflow server using your credentials." The environment variable MLFLOW_SERVER_CORS_ALLOWED_ORIGINS does the same.

The Example​

A tracking server in a folder called demo-server, on port 8090. A browser sends a page's origin in the Origin header of each request it makes for that page; curl sends the same header with -H, so you can see what the server answers without writing the app. The request searches the server's experiments, the kind of call a dashboard makes.

Prerequisites​

  • MLflow, in a project of its own. This guide uses MLflow 3.18.0.

Step 1: See the Default Refuse the App​

Terminal 1 (in demo-server)
uv run mlflow server --port 8090
Terminal 2
curl -i -X POST -H "Origin: http://app.localhost:3000" -H "Content-Type: application/json" -d '{"max_results": 1}' http://127.0.0.1:8090/api/2.0/mlflow/experiments/search
Output
HTTP/1.1 403 Forbidden
date: Sat, 28 Nov 2026 13:58:44 GMT
server: uvicorn
content-type: text/plain
access-control-allow-credentials: true
access-control-expose-headers: *
vary: Origin
Transfer-Encoding: chunked

Cross-origin request blocked

A terminal running the POST request with Origin http://app.localhost:3000: 403 Forbidden and Cross-origin request blocked.

Step 2: Allow the App's Origin​

Stop the server with Ctrl+C, and start it again with the app's origin:

Terminal 1
uv run mlflow server --port 8090 --cors-allowed-origins "http://app.localhost:3000"

Send the same request:

Terminal 2
curl -i -X POST -H "Origin: http://app.localhost:3000" -H "Content-Type: application/json" -d '{"max_results": 1}' http://127.0.0.1:8090/api/2.0/mlflow/experiments/search
Output (excerpt)
HTTP/1.1 200 OK
date: Sat, 28 Nov 2026 13:58:54 GMT
server: uvicorn
content-type: application/json
content-length: 333
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
access-control-allow-origin: http://app.localhost:3000
access-control-allow-credentials: true
vary: Origin, Origin
access-control-expose-headers: *

A terminal running the same POST request after allowing the origin: 200 OK and access-control-allow-origin http://app.localhost:3000.

The server answered 200 OK with the experiments, and access-control-allow-origin: http://app.localhost:3000 tells the browser the page may read the answer.

Common Mistakes​

MistakeWhat happensDo this instead
A slash at the end: --cors-allowed-origins "http://app.localhost:3000/"An origin never ends in a slash, and MLflow compares the text exactly: the app's POST still got 403 and Cross-origin request blockedWrite the scheme, name and port only
Expecting the option to replace the localhost defaultIt adds to it: with the option set, a POST with Origin: http://localhost:5173 still got 200 OKNothing to do: localhost and 127.0.0.1 origins stay allowed

Troubleshooting​

SymptomLikely causeFix
403 Forbidden and Cross-origin request blockedThe page's origin isn't allowedAdd it to --cors-allowed-origins
A GET from the app gets 200 OK, but the page can't read the answerMLflow blocks only requests that change data, such as POST; for a GET from an origin it doesn't allow, it answers without access-control-allow-origin, and the browser keeps the answer from the pageAdd the origin, and restart the server

FAQ​

Is --allowed-hosts the same thing?​

No. --allowed-hosts checks the name the request is addressed to, --cors-allowed-origins the page the request comes from. A web app on another address that calls the server by another name needs both.

Why do localhost origins stay allowed?​

That's how MLflow 3.18.0's code works: it never blocks a request whose origin is localhost, 127.0.0.1 or [::1], whatever the option says.

Conclusion​

The server refused the app's POST with 403 Cross-origin request blocked until --cors-allowed-origins "http://app.localhost:3000" added the origin; then it answered 200 OK with access-control-allow-origin: http://app.localhost:3000.

Additional Resources​