Sequoia
Sequoia

Reputation: 11

AuthJS with Sveltekit deployed in AWS: UntrustedHost: Host must be trusted

I have a sveltekit app using AuthJS for OAuth provider login deployed in AWS. I followed the documentation and added AUTH_TRUST_HOST set to true in the environment configuration of my Elastic Beanstalk environment. However, I still get the UntrustedHost error.

here is my auth.ts

import { SvelteKitAuth } from '@auth/sveltekit';
import Google from '@auth/core/providers/google';
import AzureAD from '@auth/core/providers/azure-ad';

export const { handle, signIn, signOut } = SvelteKitAuth({
    providers: [
        Google({
            authorization: {
                params: {
                    scope: 'openid profile email'
                }
            }
        }),
        AzureAD
    ],
    callbacks: {
        jwt({ token, account }) {
            if (account) {
                return {
                    ...token,
                    accessToken: account.access_token,
                    provider: account.provider
                };
            }
            return token;
        },
        session({ session, token }) {
            return {
                ...session,
                user: {
                    ...session.user,
                    accessToken: token.accessToken,
                    provider: token.provider
                }
            };
        }
    },
    trustHost: true,
    session: {
        maxAge: 60 * 60 * 8,
        strategy: 'jwt'
    }
});

Upvotes: 1

Views: 40

Answers (0)

Related Questions