diff --git a/packages/lib/next-auth/auth-options.ts b/packages/lib/next-auth/auth-options.ts index f5b0779cf..f0006030e 100644 --- a/packages/lib/next-auth/auth-options.ts +++ b/packages/lib/next-auth/auth-options.ts @@ -26,7 +26,8 @@ import { extractNextAuthRequestMetadata } from '../universal/extract-request-met import { getAuthenticatorOptions } from '../utils/authenticator'; import { ErrorCode } from './error-codes'; -const useSecureCookies = process.env.NODE_ENV === 'production'; +const useSecureCookies = + process.env.NODE_ENV === 'production' && String(process.env.NEXTAUTH_URL).startsWith('https://'); const cookiePrefix = useSecureCookies ? '__Secure-' : ''; export const NEXT_AUTH_OPTIONS: AuthOptions = {