HomeChallengesRepsProblemsLeaderboardTake a challenge

The API only your laptop can call

Works on every laptop, blocked in production, and the laptop version lets any website call the API as the signed-in user. Configure CORS once, properly, for every environment.

Beginner15 min on the clock6 graded checks · 100 pointsServices That Fail Politely
Graded by reading your code against the checklist below.

What you build

  • Register one named CORS policy with AddCors
  • Read the allowed origins from configuration, not from code
  • Apply the policy in every environment, not just Development
  • Run UseCors before UseAuthentication and UseAuthorization
  • Keep AllowCredentials, but only with a named list of origins
  • Put the production origin in appsettings.Production.json

Done means

One named policy, origins from configuration, applied in every environment before auth, credentials only with explicit origins.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. One named policy, registered and applied+20Who the browser lets call you
  2. The allowed origins come from configuration+20Who the browser lets call you
  3. CORS is on in every environment+20Who the browser lets call you
  4. UseCors runs before authorization+15Who the browser lets call you
  5. Credentials only with named origins+15Who the browser lets call you
  6. Production lists its exact origin+10Settings, not string literals

What it teaches

The rest of Services That Fail Politely