Compare commits

...

2 Commits

Author SHA1 Message Date
Thang Vu
69f2c37920 use declare env 2023-01-29 19:15:19 +07:00
Thang Vu
fc5c97db66 fix: use $env/static/private in framework-sveltekit 2023-01-28 12:15:14 +07:00

View File

@@ -190,7 +190,7 @@
import type { Handle } from "@sveltejs/kit" import type { Handle } from "@sveltejs/kit"
import { dev } from "$app/environment" import { dev } from "$app/environment"
import { env } from "$env/dynamic/private" import { AUTH_SECRET, AUTH_TRUST_HOST, VERCEL } from "$env/static/private"
import { Auth } from "@auth/core" import { Auth } from "@auth/core"
import type { AuthAction, AuthConfig, Session } from "@auth/core/types" import type { AuthAction, AuthConfig, Session } from "@auth/core/types"
@@ -199,7 +199,7 @@ export async function getSession(
req: Request, req: Request,
config: AuthConfig config: AuthConfig
): ReturnType<App.Locals["getSession"]> { ): ReturnType<App.Locals["getSession"]> {
config.secret ??= env.AUTH_SECRET config.secret ??= AUTH_SECRET
config.trustHost ??= true config.trustHost ??= true
const url = new URL("/api/auth/session", req.url) const url = new URL("/api/auth/session", req.url)
@@ -261,8 +261,8 @@ function AuthHandle(prefix: string, authOptions: AuthConfig): Handle {
*/ */
export function SvelteKitAuth(options: SvelteKitAuthConfig): Handle { export function SvelteKitAuth(options: SvelteKitAuthConfig): Handle {
const { prefix = "/auth", ...authOptions } = options const { prefix = "/auth", ...authOptions } = options
authOptions.secret ??= env.AUTH_SECRET authOptions.secret ??= AUTH_SECRET
authOptions.trustHost ??= !!(env.AUTH_TRUST_HOST ?? env.VERCEL ?? dev) authOptions.trustHost ??= !!(AUTH_TRUST_HOST ?? VERCEL ?? dev)
return AuthHandle(prefix, authOptions) return AuthHandle(prefix, authOptions)
} }
@@ -278,7 +278,7 @@ declare global {
} }
} }
declare module "$env/dynamic/private" { declare module "$env/static/private" {
export const AUTH_SECRET: string export const AUTH_SECRET: string
export const AUTH_TRUST_HOST: string export const AUTH_TRUST_HOST: string
export const VERCEL: string export const VERCEL: string