Auth.js - UntrustedHost: Host must be trusted.
mikenikles
PROOP

a year 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

Pinned Solution

a year 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.

2 Replies

a year 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
PROOP

a year 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 11 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...