Mongodb-realm folder is not created on google cloud function

I have google cloud function with mongo node js sdk where I call realm function to get the data.
During function execution sdk tries to create Mongodb-realm folder and some files there for sync purposes (why it was done in this way? I do not want it happen at all, for me it looks like security issue
)


Error: Unable to open a realm at path '/workspace/mongodb-realm/products-gjstr/server-utility/metadata/sync_metadata.realm.lock'. Please use a path where your app has read-write permissions.

As I understood it’s not possible to prevent this folder being created. I need somehow give permissions for function to create this folder. Can not find how to do it. Any recommendations?

Also is it possible to call the realm function via http? I just need to get the data and I do not care about sync sdk capabilities and so on

Hi @Denys_Medvediev,

The SDK is supposed to work with clients (especially mobile), not from a backend function, and it keeps a local copy of the DB to enable the offline functionality.

You can try to use the Realm Web SDK, that doesn’t, at this time, support the offline functionality, and allows you to call functions.

Yes, it is: you must of course do what the SDK does behind the scenes first:

  • Determine the location of your app: https://realm.mongodb.com/api/client/v2.0/app/<app-id>/location: this will return the hostname you should use for the next queries
  • Authenticate your user, and get the JWT token you’ll use for the next calls
  • Call the function with
    • Authorization Bearer Token with the access token you got from the previous call
    • a POST to https://<hostname>/api/client/v2.0/app/<app-id>/functions/call, with a JSON payload like
{
  "name": "<function name>",
  "arguments": [<argument list>]
}
1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.