Skip to content

CORS: allow_origins=['*'] with allow_credentials=True is invalid #13

Description

@jtdub

Problem

In main.py:18-24:

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    ...
)

Per the CORS specification, browsers will reject responses that use Access-Control-Allow-Origin: * together with Access-Control-Allow-Credentials: true. This combination is explicitly forbidden.

Suggested Fix

Either:

  • Remove allow_credentials=True if credentials aren't needed, or
  • Replace allow_origins=["*"] with a list of specific allowed origins (configurable via environment variable).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions