Back

[Solved] How to use Locale service, server side ?

  • 0
  • Functions
  • Locale
punti_z
7 Apr, 2023, 19:53

I want to get users location server side. Looking at documentation the locale.get() doesn't ask for user ID or any other details? What users locale will it provide ?

I am trying to restrict access to information based of user location. A request document is created in a collection and information is populated in the document basis country by a cloud function.

TL;DR
The user wants to know how to use the Locale service server-side. The answer is that the common use case is for API calls to be made from the client. If you call locale.get server-side, it will return the location of the server. It is best to use locale on the client-side only. The API grabs the IP address of the requester and looks up the location based on that. If you make the API call from another server, the request will come from your server, not the end user. The user wants to get the user's location server-side but the locale.get() function doesn't ask for the user ID or
Drake
7 Apr, 2023, 20:46

That API grabs the IP address of the requester and looks up the location based on the IP. If you're making the API call from some other server the request will come from your server rather than the end user.

punti_z
7 Apr, 2023, 20:49

So calling locale.get server side (using appwrite functions) would return location of the server then ? Not sure I understand the use case of that..

So ideally locale should be used client side only

Drake
7 Apr, 2023, 20:51

Yes. The common use case is for api calls to be made from the client

punti_z
7 Apr, 2023, 20:52

[Solved] How to use Locale service, server side ?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more