diff --git a/backend/src/main.ts b/backend/src/main.ts index 438b2d9..034f88b 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -3,7 +3,10 @@ import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); - +app.enableCors({ + origin: 'http://localhost:3000', + credentials: true, + }); const port = process.env.PORT || 3001; await app.listen(port); diff --git a/frontend/app/test/page.tsx b/frontend/app/test/page.tsx new file mode 100644 index 0000000..8a0651d --- /dev/null +++ b/frontend/app/test/page.tsx @@ -0,0 +1,63 @@ +'use client'; + +import { useEffect } from 'react'; + +export default function TestPage() { + useEffect(() => { + console.log('--- FE TEST START ---'); + + // Feed testen + fetch('http://localhost:3001/feed') + .then(res => res.json()) + .then(data => { + console.log('FEED RESPONSE:', data); + }) + .catch(err => { + console.error('FEED ERROR:', err); + }); + + // Öffentliches Pet testen + fetch('http://localhost:3001/pets/2') + .then(async res => { + if (res.status === 403) { + console.log('PET 2: FORBIDDEN'); + return; + } + const data = await res.json(); + console.log('PET 2 RESPONSE:', data); + }) + .catch(err => { + console.error('PET 2 ERROR:', err); + }); + + // Followers-Pet testen (soll 403 geben) + fetch('http://localhost:3001/pets/5') + .then(async res => { + if (res.status === 403) { + console.log('PET 5: FORBIDDEN (expected)'); + return; + } + const data = await res.json(); + console.log('PET 5 RESPONSE:', data); + }) + .catch(err => { + console.error('PET 5 ERROR:', err); + }); + }, []); + + return ( +
+

🧪 Frontend API Test

+

+ Diese Seite dient nur zum Testen der Backend-APIs. +
+ 👉 Öffne die Browser-Konsole. +

+ +
+ ); +}