[SOLVED]:Access to external mysql db for normal user - Error: Unable to handle the request. Contact the site administrator

Hi,
I need some help :slight_smile:
I have a mysql db on google. I can see it in the database tab.
But access is fixed to Admin, I can not change that.


I can query my db as a Admin using the preview view.
But this is not possible when I deploy in test.
I get the follwoing:
“Error: Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.”

I can fetch my data as Admin but not as user. I tried by moving the query call to the backend and adding suppressAuth. But that did not help.

Any ideas about how to proceed ??

code below:

I have moved my query to a db.jsw in backend
db.jsw
import wixData from ‘wix-data’ ;

export function searchAdress_back () {
return wixData . query ( “mysql/search_view” )
. limit ( 2000 )
. find ({ suppressAuth : true })
. then ( ( results ) => {
return results ;
});
}

Mainpage main.js

import { searchAdress_back } from ‘backend/db’ ;

function searchAdress ( params ) {
let adress ;
adress = $w ( ‘#addressInput1’ ). value ;
let lat = adress.location.latitude ;
let long = adress.location.longitude ;

// gethold of db data and querry
let db ;
filteredResult = ;
tableSet = ;
searchAdress_back ()
. then ( ( results )=> {
db = results ;
console.log(db);
…
…
…
}). catch ( e => {
console . log ( “Error query:” )
console . log ( e );
});
}

Running this code gives me the permission error in the header. “Unable to handle the request. Contact the site administrator” Any suggestions on how to gives access / query the database for a normal user?

I followed this guide. But still same problem. https://www.wix.com/velo/forum/tips-tutorials-examples/tutorial-how-to-bypass-collection-permissions-and-hooks

Solved: Needed to add a JSON permission file to my google cloud service
Example PERMISSIONS value:
{
“collectionPermissions”: [
{
“id”: “Contacts”,
“read”: [“Admin”, “Member”],
“write”: [“Admin”]
}
]
}