Skip to content

getting "SvelteKitError: Not found: /signin/..-" after updating to svelte 5 #12816

Open
@martin-gif

Description

@martin-gif

Environment

System:
OS: macOS 15.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 89.30 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - /etc/profiles/per-user/marvin/bin/node
Yarn: 1.22.21 - /opt/homebrew/bin/yarn
npm: 10.9.2 - /etc/profiles/per-user/marvin/bin/npm
Browsers:
Safari: 18.3
npmPackages:
@auth/prisma-adapter: ^2.8.0 => 2.8.0
@auth/sveltekit: ^1.7.4 => 1.8.0

Reproduction URL

https://github.com/martin-gif/sveltekit-auth-example

Describe the issue

Nach dem Update auf Svelte 5 mit svelte kit 2 bekommen ich bei einer Clint side 'signIn' den Fehler SvelteKitError: Not found: /signin/keycloak und einen Status '404'. Der Button ist relativ simple:

import { signIn, signOut } from '@auth/sveltekit/client';
<button
 onclick={() => signIn('keycloak')}
>
Login
</button>

hier noch einmal mein src/auth.ts

import { SvelteKitAuth } from '@auth/sveltekit';
import { PrismaAdapter } from '@auth/prisma-adapter';
import { prisma } from '$lib/server/DB';
import Keycloak from '@auth/sveltekit/providers/keycloak';

export const { signIn, signOut, handle } = SvelteKitAuth({
	debug: true,
	adapter: PrismaAdapter(prisma),
	providers: [Keycloak],
	callbacks: {
		session({ session, user }) {
			session.user.id = user.id; // kann man später mal schauen, ob man das angreifen kann
			return session;
		}
	}
});

and src/hooks.server.ts

import { redirect, type Handle } from '@sveltejs/kit';
import { handle as authenticationHandle } from './auth';
import { sequence } from '@sveltejs/kit/hooks';

const authentication: Handle = async ({ event, resolve }) => {
	if (event.url.pathname.endsWith('/feedback')) {
		const session = await event.locals.auth();
		if (!session) {
			throw redirect(303, '/auth/signin');
		}
	}
	return resolve(event);
};

export const handle: Handle = sequence(authenticationHandle, authentication);

i'm still quite new to svelte web development, so unfortunately i can't rule out the possibility that i made the mistake. If there is any information missing, I can provide it. the bug exists in the @auth/sveltekit versions 1.7.3,1.7.4,1.8.0.

How to reproduce

  • Download repo from the link provided
  • install packages (I used Yarn in the repo)
  • start page with vite dev
  • click login button

Expected behavior

the keycloak login page opens and you can log in as a user

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions