Many to any item won't fetch data on first load on Safari iOS

Hello everyone,
i’m building a small website with Directus, its SDK, and Sveltekit.

Everything works like a charm but i can’t figure out an issue with the Safari browser on iOS.

The problem
For building pages content i have multiple blocks, one of these is a block_gallery which contains a multiple files input.
When i’m using iOS Safari and i first load a page that contains a gallery the results in the array are “undefined” but the array length is correct. If i navigate to another page and go back to the previous the results will appear correctly.

I don’t understand if it is a Safari issue with deep nested results or something that i’m missing.
Maybe someone can help me somehow?

Thanks to everyone that will answer!

**My code example for fetch **
For those who know Sveltekit that’s what is in my load function in page.ts

const client = getDirectusInstance(fetch);
await client.request(readItem('pages', 'home', {
        fields: [
            {
                blocks: [
                    {
                        "item": ['*', {
                            block_gallery: ['*', { gallery: ['*', 'directus_files_id.*'] }]
                        }]
                    }
                ]
            },
        ],

        filter: {
            status: { _eq: "published" }
        },
    }));

2 Answers

2

This might be a permissions issue where your getDirectusInstance is conditionally attaching a token with read permissions on your gallery collection..

The initial navigation will run this code on the server and subsequent requests will run on the client.

Check your public permissions and user permissions if you are conditionally attaching a token on the server.

Ehi Alex, thanks for your answer!
I don’t know if that’s what you mean but those collections: block_gallery and block_gallery_files, have both full read permissions for the public role / policy so it shouldn’t be a problem. Plus my getDirectusInstance is really basic, i’m just passing the Svelte fetch function to the instance, i don’t have auth or something else.

Let me know if i’m missing something