Publisert - 07.05.2026

Configuration

Configuration Files

File Purpose Git tracked
appsettings.json Base configuration (shared across environments) Yes
appsettings.Development.json Development overrides (API keys, local settings) No (in .gitignore)
appsettings.{Environment}.json Environment-specific overrides Depends on environment

Configuration Keys

MongoDB

Key Description Default
ConnectionStrings:DefaultConnection MongoDB connection string mongodb://localhost:27017
MongoDB:DatabaseName Database name nompd

Upstream Sync

Key Description Default
Sync:UpstreamBaseUrl Base URL for upstream FHIR APIs https://legemidler-api-test.azurewebsites.net/api/v1
Sync:UpstreamApiKey API key for authenticating with upstream APIs None (required)

The UpstreamApiKey should be placed in appsettings.Development.json for local development:

{
  "Sync": {
    "UpstreamApiKey": "your-key-here"
  }
}

In production, use environment variables or a secrets manager:

Sync__UpstreamApiKey=your-production-key

API Keys

Key Description Default
ApiKeys Array of valid API keys for authenticating consumers []
{
  "ApiKeys": [
    "client-key-1",
    "client-key-2"
  ]
}

All endpoints require a valid X-API-KEY header matching one of the configured keys.

Logging

Standard ASP.NET Core logging configuration under the Logging section. Default levels:

  • Default: Information
  • Microsoft.AspNetCore: Warning

CORS

CORS is configured in Program.cs to allow http://localhost:5173 (frontend dev server). Modify the origin list for production deployments.

Environment Variables

All configuration keys can be overridden with environment variables using the __ separator:

ConnectionStrings__DefaultConnection=mongodb://prod-server:27017
MongoDB__DatabaseName=nompd-prod
Sync__UpstreamBaseUrl=https://legemidler-api.azurewebsites.net/api/v1
Sync__UpstreamApiKey=prod-api-key
ApiKeys__0=client-key-1
ApiKeys__1=client-key-2

Secrets Handling

Never commit API keys or secrets to source control.

Secret Where to configure
Sync:UpstreamApiKey appsettings.Development.json (local), K8s Secret (prod)
ApiKeys appsettings.Development.json (local), K8s Secret (prod)
MongoDB credentials Connection string in environment variable (prod)

Søk i Utviklerportalen

Søket er fullført!