Auth.js - UntrustedHost: Host must be trusted.

mikenikles
PRO

2 months ago

Hello,

I'm trying to deploy a https://remult.dev app based on SvelteKit. I use SvelteKit's adapter-node and get the following error in the deployment logs:

[auth][error] UntrustedHost: Host must be trusted. URL was: https://healthcheck.railway.app/auth/session. Read more at https://errors.authjs.dev#untrustedhost

The Auth.js docs (link) say that setting AUTH_TRUST_HOST="true" should be all that's needed. However, that doesn't seem to be the case... or of course, there's a chance I misunderstood something.

Has anyone seen / resolved that issue?

Solved$10 Bounty

2 Replies

2 months ago

Auth.js blocks hosts it doesn’t recognize. Railway’s health-checker calls https://healthcheck.railway.app, which isn’t in the allowed list, so you see “UntrustedHost”.

Try this:

// src/hooks.server.ts
import { handleAuth } from "@auth/sveltekit";

export const handle = handleAuth({
  trustHost: true     
});

If it doesn't fix immediatly, you can do it the env variables.


mikenikles
PRO

2 months ago

Thank you, hard-coding it in the config works. I already had AUTH_TRUST_HOST="true" set in my Railway variables, but that didn't seem to get picked up.


Status changed to Solved chandrika about 2 months ago


Auth.js - UntrustedHost: Host must be trusted. - Railway Help Station