diff --git a/frontend/app/login/page.tsx b/frontend/app/login/page.tsx index c7aa4772..a781afbf 100644 --- a/frontend/app/login/page.tsx +++ b/frontend/app/login/page.tsx @@ -96,84 +96,3 @@ export default function LoginPage() { ); } - - - const [username, setUsername] = useState(''); - const [password, setPassword] = useState(''); - const [error, setError] = useState(''); - const [loading, setLoading] = useState(false); - - async function handleSubmit(e: FormEvent) { - e.preventDefault(); - setError(''); - setLoading(true); - const result = await signIn('credentials', { - username, - password, - redirect: false, - }); - setLoading(false); - if (result?.error) { - setError('Felaktigt användarnamn eller lösenord'); - } else { - router.push(callbackUrl); - router.refresh(); - } - } - - return ( -
-

Logga in

-
-
- - setUsername(e.target.value)} - required - autoComplete="username" - style={{ width: '100%', padding: '8px 12px', borderRadius: 6, border: '1px solid #ccc', fontSize: '1rem' }} - /> -
-
- - setPassword(e.target.value)} - required - autoComplete="current-password" - style={{ width: '100%', padding: '8px 12px', borderRadius: 6, border: '1px solid #ccc', fontSize: '1rem' }} - /> -
- {error &&

{error}

} - -

- Inget konto? Skapa konto -

-
-
- ); -} diff --git a/frontend/auth.ts b/frontend/auth.ts index 5068beb6..7fe88182 100644 --- a/frontend/auth.ts +++ b/frontend/auth.ts @@ -1,7 +1,7 @@ import NextAuth from 'next-auth'; import Credentials from 'next-auth/providers/credentials'; -const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL ?? 'http://recipe-api:3000/api'; +const BACKEND_URL = process.env.NEXT_PUBLIC_API_URL_INTERNAL ?? 'http://recipe-api:8080'; export const { handlers, auth, signIn, signOut } = NextAuth({ providers: [ @@ -13,7 +13,7 @@ export const { handlers, auth, signIn, signOut } = NextAuth({ async authorize(credentials) { if (!credentials?.username || !credentials?.password) return null; try { - const res = await fetch(`${BACKEND_URL}/auth/login`, { + const res = await fetch(`${BACKEND_URL}/api/auth/login`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({