Skip to content

Untrusted Host even while AUTH_TRUST_HOST is set #13355

@Lite5h4dow

Description

@Lite5h4dow

Environment

  System:
    OS: Linux 6.15 cpe:/o:nixos:nixos:25.11 25.11 (Xantusia)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 2.64 GB / 15.46 GB
    Container: Yes
    Shell: 5.3.3 - /nix/store/ciarnmsx8lvsrmdbjddpmx0pqjrm8imb-bash-5.3p3/bin/bash
  Binaries:
    Node: 22.20.0 - /nix/store/nvf9kaarb9kqqdbygl9cbzhli1y8yjik-nodejs-22.20.0/bin/node
    Yarn: 1.22.22 - /nix/store/37pxb8rr3g0csqbxajxqjmjvhwpfa35v-yarn-1.22.22/bin/yarn
    npm: 10.9.3 - /nix/store/nvf9kaarb9kqqdbygl9cbzhli1y8yjik-nodejs-22.20.0/bin/npm
    pnpm: 10.19.0 - /nix/store/q2gm8j153ywipq98wasmhjnscmc015zr-pnpm-10.19.0/bin/pnpm
  npmPackages:
    @auth/sveltekit: ^1.11.1 => 1.11.1
    svelte: ^5.46.1 => 5.46.1

Reproduction URL

https://git.litelot.us/litelotus/personal-site

Describe the issue

When attempting to login or use any path that requires authentication, auth.js produces the following error:

[auth][error] UntrustedHost: Host must be trusted. URL was: https://litelot.us/auth/signin. Read more at https://errors.authjs.dev#untrustedhost                                 │
│     at assertConfig (file:///server/server/chunks/hooks.server-IWBkrb2r.js:521:12)                                                                                               │
│     at Auth (file:///server/server/chunks/hooks.server-IWBkrb2r.js:7275:27)

with this warning on startup:

│ [auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev                                                                                                  ```

### How to reproduce

1. setup any project behind a reverse-proxy
2. have `NODE_ENV` set to `production`
3. optionally have `AUTH_URL` set to domain. in my case `https://litelot.us/auth/login` (see: [deployment permanlink](https://git.litelot.us/litelotus/personal-site/src/commit/42813dd4e95260b8b0fb8c636786cec4538f6b21/pulumi/main.go#L198)
4. MUST have `AUTH_TRUST_HOST` set to `true`
5. server will 500 if you even think about anything regarding auth.js

### Expected behavior

authjs should either render signin page, or run the authorization flow

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalid reproductionThe issue did not have a detectable valid reproduction URLtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions