WixData Query to "Media/Files" works in preview but fails on the live site

The code is simple (below), it works perfectly in preview but I get an error (also below) on the live site. Does anyone have any idea why this is happening?


    wixData.query("Media/Files")
    .find()
    .then((results) => {
        console.log(results);
    });

In preview the code returns an object as expected with 50 items from the media gallery, but on the live site it outputs this error:

Error: WDE0053: Internal wixData error: WDE0054: The server could not fulfill the request

Update: I avoided the issue by loading all the images needed into a custom collection and querying the new collection. That said, this is still an issue because it should be possible to directly query the “Media/Files” collection.

Are you running it on → BACKEND ? If not, it won’t work.

https://www.wix.com/velo/reference/wix-media-backend/introduction

Thank you, this is probably the issue; I wasn’t running it on the backend. However, it would still be a bug if it works on preview and not on the live site.

First try on BACKEND.
It should work.

I already moved it to its own collection to avoid the problem so I’ll leave it as is, but this is good to know for the future :smiley: Thank you!