CORS and credentials in AgentOS

How AgentOS handles wildcard origins and credentialed browser requests

AgentOS turns off credentialed CORS when you allow every origin, so other websites can’t use your users’ cookies to call your agents.

Diagram

Yes

No

🌐 Browser request

🛡️ cors_origins has ‘*’?

🚫 Credentials not allowed

✅ Credentials allowed

Quick Start

  1. Public endpoint, no cookies
    python
    from praisonai import AgentOS
    from praisonaiagents import Agent
    
    agent = Agent(instructions="Be helpful")
    
    AgentOS(
        agents=[agent],
        cors_origins=["*"],  # Any site can call it. Credentials are dropped.
    ).serve()
  2. Browser app with cookies
    python
    from praisonai import AgentOS
    from praisonaiagents import Agent
    
    agent = Agent(instructions="Be helpful")
    
    AgentOS(
        agents=[agent],
        cors_origins=["https://app.example.com"],  # Credentialed CORS works.
    ).serve()

How It Works

Diagram
AgentOSBrowserAgentOSBrowserBrowser blocks the responseResponse deliveredalt[cors_origins contains “*”][explicit origin matches]fetch(…, credentials: “include”)No Access-Control-Allow-CredentialsAllow-Origin: https://app.example.comAllow-Credentials: true
cors_originsCredentials (cookies, credentialed fetch)
[] (default)No cross-origin access
["*"]Not allowed
["https://app.example.com"]Allowed for that origin
["https://app.example.com", "*"]Not allowed — any "*" turns credentials off

The same rule applies to the async jobs server when you pass cors_origins to praisonai.jobs.server.create_app.


Why

With a "" origin and credentials both enabled, Starlette’s CORS middleware echoes the caller’s Origin header back when a cookie is present. Any website could then make logged-in requests to your deployment. Browsers forbid with credentials for this reason, and AgentOS enforces the same rule on the server.


Best Practices

List exact frontend origins in production

Use cors_origins=["https://app.example.com"] instead of ["*"] for any deployed frontend.

Never mix "*" with other origins

One "*" entry turns credentials off for the whole list.

Check browser clients after upgrading

If cookie-based browser calls stopped working after an upgrade, you were relying on ["*"] with credentials. Switch to an explicit origin list.


Related