Compare commits
	
		
			2 Commits
		
	
	
		
			b534cd1ddc
			...
			bda30eb42d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						bda30eb42d
	
				 | 
					
					
						|||
| 
						
						
							
						
						9f53e331a7
	
				 | 
					
					
						
@@ -10,10 +10,20 @@ export async function getUserFavorites(fetch: any, locals: any): Promise<string[
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        const favRes = await fetch('/api/rezepte/favorites');
 | 
					        // Use absolute URL for internal server-side fetch to avoid nginx routing issues
 | 
				
			||||||
 | 
					        const baseUrl = process.env.NODE_ENV === 'production' 
 | 
				
			||||||
 | 
					            ? 'http://localhost:3000' 
 | 
				
			||||||
 | 
					            : 'http://localhost:5173';
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        console.log(`Fetching favorites from: ${baseUrl}/api/rezepte/favorites`);
 | 
				
			||||||
 | 
					        const favRes = await fetch(`${baseUrl}/api/rezepte/favorites`);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        if (favRes.ok) {
 | 
					        if (favRes.ok) {
 | 
				
			||||||
            const favData = await favRes.json();
 | 
					            const favData = await favRes.json();
 | 
				
			||||||
 | 
					            console.log(`Loaded ${favData.favorites?.length || 0} favorites for user ${session.user.nickname}`);
 | 
				
			||||||
            return favData.favorites || [];
 | 
					            return favData.favorites || [];
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            console.error(`Favorites fetch failed with status: ${favRes.status}`);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
        // Silently fail if favorites can't be loaded
 | 
					        // Silently fail if favorites can't be loaded
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,22 +1,18 @@
 | 
				
			|||||||
import type { PageServerLoad } from "./$types";
 | 
					import type { PageServerLoad } from "./$types";
 | 
				
			||||||
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
 | 
					import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function load({ fetch, locals }) {
 | 
					export async function load({ fetch, locals, parent }) {
 | 
				
			||||||
    let current_month = new Date().getMonth() + 1
 | 
					    let current_month = new Date().getMonth() + 1
 | 
				
			||||||
    const res_season = await fetch(`/api/rezepte/items/in_season/` + current_month);
 | 
					    const res_season = await fetch(`/api/rezepte/items/in_season/` + current_month);
 | 
				
			||||||
    const res_all_brief = await fetch(`/api/rezepte/items/all_brief`);
 | 
					    const res_all_brief = await fetch(`/api/rezepte/items/all_brief`);
 | 
				
			||||||
    const item_season = await res_season.json();
 | 
					    const item_season = await res_season.json();
 | 
				
			||||||
    const item_all_brief = await res_all_brief.json();
 | 
					    const item_all_brief = await res_all_brief.json();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Get user favorites and session
 | 
					    // Get user favorites (session comes from parent layout)
 | 
				
			||||||
    const [userFavorites, session] = await Promise.all([
 | 
					    const userFavorites = await getUserFavorites(fetch, locals);
 | 
				
			||||||
        getUserFavorites(fetch, locals),
 | 
					 | 
				
			||||||
        locals.auth()
 | 
					 | 
				
			||||||
    ]);
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        season: addFavoriteStatusToRecipes(item_season, userFavorites),
 | 
					        season: addFavoriteStatusToRecipes(item_season, userFavorites),
 | 
				
			||||||
        all_brief: addFavoriteStatusToRecipes(item_all_brief, userFavorites),
 | 
					        all_brief: addFavoriteStatusToRecipes(item_all_brief, userFavorites)
 | 
				
			||||||
        session
 | 
					 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,12 @@ const config = {
 | 
				
			|||||||
		// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
 | 
							// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
 | 
				
			||||||
		// If your environment is not supported or you settled on a specific environment, switch out the adapter.
 | 
							// If your environment is not supported or you settled on a specific environment, switch out the adapter.
 | 
				
			||||||
		// See https://kit.svelte.dev/docs/adapters for more information about adapters.
 | 
							// See https://kit.svelte.dev/docs/adapters for more information about adapters.
 | 
				
			||||||
		adapter: adapter()
 | 
							adapter: adapter(),
 | 
				
			||||||
 | 
							// Temporarily disable CSRF protection for local testing
 | 
				
			||||||
 | 
							// TODO: Remove this after debugging production issue
 | 
				
			||||||
 | 
							csrf: {
 | 
				
			||||||
 | 
								checkOrigin: false
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,5 +2,8 @@ import { sveltekit } from '@sveltejs/kit/vite';
 | 
				
			|||||||
import { defineConfig } from 'vite';
 | 
					import { defineConfig } from 'vite';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default defineConfig({
 | 
					export default defineConfig({
 | 
				
			||||||
 | 
						server: {
 | 
				
			||||||
 | 
							allowedHosts: ["bocken.org"]
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	plugins: [sveltekit()],
 | 
						plugins: [sveltekit()],
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user