Kind: Service
Source: Pams/API/Pams.API/Pams.API.csproj (line 1)
Part of: Pams
NuGet package dependency
Microsoft.Owin.Cors is a NuGet package dependency for the Pams API project that enables Cross-Origin Resource Sharing headers in the OWIN request pipeline. It allows browser clients hosted on permitted origins to send requests to API endpoints and receive CORS-enabled responses.
Diagram
mermaidsequenceDiagram participant Client as Browser Client participant API as Pams API participant CORS as OWIN CORS Middleware Client->>API: OPTIONS or API request API->>CORS: Process request headers CORS-->>API: Add allowed CORS headers API-->>Client: CORS-enabled response
Usage
typescriptconst response = await fetch("https://api.example.com/pams/items", {
method: "GET",
headers: {
Accept: "application/json",
},
});
if (!response.ok) {
throw new Error(`API request failed: ${response.status}`);
}
const items = await response.json();
console.log(items);
AI Coding Instructions
- Configure CORS in the OWIN startup pipeline before Web API middleware handles requests.
- Restrict allowed origins, methods, and headers instead of enabling CORS for every origin unless the API contract requires it.
- Confirm that preflight
OPTIONSrequests reach the CORS middleware and are not blocked by authentication or routing. - Keep browser client origins aligned with the API CORS policy when adding new frontend environments.
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
Was this page helpful?