# System.Web.Http.Cors

**Kind:** Service

**Source:** `Pams/API/Pams.API/Pams.API.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`System.Web.Http.Cors` is a NuGet package dependency for the legacy ASP.NET Web API project in `Pams.API`. It enables the API to apply Cross-Origin Resource Sharing policies so browser clients from allowed origins can call HTTP endpoints.

## Diagram

```mermaid
sequenceDiagram
    participant Browser as Browser Client
    participant API as Pams.API
    participant CORS as System.Web.Http.Cors

    Browser->>API: OPTIONS preflight request
    API->>CORS: Evaluate origin and request headers
    CORS-->>API: Return CORS response headers
    API-->>Browser: Preflight response
    Browser->>API: API request with Origin header
    API-->>Browser: API response with CORS headers
```

## Usage

```ts
const response = await fetch("https://api.example.com/api/patients", {
  method: "GET",
  headers: {
    Accept: "application/json",
  },
});

if (!response.ok) {
  throw new Error(`API request failed: ${response.status}`);
}

const patients = await response.json();
console.log(patients);
```

## AI Coding Instructions

- Treat `System.Web.Http.Cors` as a server-side dependency; browser code only sends requests with an `Origin` header.
- Configure allowed origins, methods, and headers in the ASP.NET Web API startup or route configuration.
- Keep CORS policy changes aligned with the client application's actual API origin.
- Check preflight `OPTIONS` requests when adding custom request headers or non-simple HTTP methods.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.API` — `Pams/API/Pams.API/Pams.API.csproj`:1
