Open ssebastianoo opened 3 months ago
I have the same issue here. @ssebastianoo Could you add back your reproduction branch? I think you deleted it by accident.
Edit:
If you didn't get this to work, this bug is caused by the inclusion of the import { env } from "$env/dynamic/private"
in the file you mentioned. This file is imported by the auth.js
file that (as per the guide you followed) contains this:
// lib/auth.ts
const providers: Provider[] = [
GitHub,
Credentials({
credentials: { password: { label: "Password", type: "password" } },
authorize(c) {
if (c.password !== "password") return null
return {
id: "test",
name: "Test User",
email: "test@example.com",
}
},
}),
]
export const providerMap = providers.map((provider) => {
if (typeof provider === "function") {
const providerData = provider()
return { id: providerData.id, name: providerData.name }
} else {
return { id: provider.id, name: provider.name }
}
})
export const { handle, signIn, signOut } = SvelteKitAuth({
providers,
pages: {
signIn: "/signin",
},
})
If you now import providerMap
(or anything else exported by this file) inside a client route, this will attempt to load $env/dynamic/private
from the @auth/sveltekit/dist/index.js
.
Fix this by simply not consuming anything from the auth.ts
file in your client routes, for me, this was as simple as not using the providerMap
and hard coding <SignIn provider="" />
in my client.
@Conceptiks yeah I deleted the branch forgetting about this issue. I solved it the same way you did, hardcoding it
Do you still need the branch? I can try to recreate it
Even if I solved it I'm not gonna close it because this is still a bug that pops up following the official documentation
Totally agree, this should not be happening.
here's how you can load on the server-side and then load in the frontend.
that's actually so smart
Will this ever be fixed ?
Environment
Reproduction URL
https://github.com/ssebastianoo/SelfStats/blob/authjs-bug/src/routes/signin/%2Bpage.svelte
Describe the issue
When trying to set up a custom sign in page the authjs library for SvelteKit tries, for some reason, to
import { env } from "$env/dynamic/private";
in the client, breaking the whole appHow to reproduce
Add a custom login page following the docs
Expected behavior
$env/dynamic/private
shouldn't be imported on the client