Skip to content

HAMUR_W2044: A route rule's basicAuth password is a literal in the config

A route rule's basicAuth password is a literal in the config. Warning HAMUR_W2044 belongs to hamur, server (2001 – 2999).

Message

text
HAMUR_W2044 Route rule "<pattern>" basicAuth.password is a literal in the config file, which ends up in the repository; use env("NAME")

Cause

A route rule's basicAuth.password is a string in the config file, which ends up in the repository.

Fix

Declare the variable in app/env.ts, write env("NAME") and set the secret in the environment.

ts
import { defineConfig, env } from "hamur"

export default defineConfig({
  framework: "react",
  routeRules: {
    "/admin/**": { basicAuth: { username: "admin", password: env("ADMIN_PASSWORD") } },
  },
})