I am helping an agrotech company to develop a web app .
We are testing farmOS on Farmier to try to develop an app to connect to it.
The first trouble was on autentication, the server has bloqued te call because of CORS policy, so i am here to ask if there is some way for me to define wich domains to allow on a farmOS instance running at farmier.com.
Awesome! Are you going to use the farmOS API in your app? If you are using JavaScript or Python you might find these helpful:
Best practice would be to create a farmOS module for your app, that you can offer to farmOS administrators (like Farmier) to install on their farmOS instances. This module could be very simple. All it needs to do is provide an OAuth2 “client” for your app to connect to. One of the configuration options of this client is allowed_origins, which configures CORS allowed origins.
Your module would only need two files in it: a *.info.yml file (described in that link) and a *.install file, which can be used to create the OAuth2 client when the module is installed (and remove it when it is uninstalled).
A simple example of this is the FieldKit module in farmOS, which allows connections from https://farmOS.app. Here is the farm_fieldkit.install file for reference:
Notice how line 37 sets 'allowed_origins' => 'https://farmos.app',.
I would recommend setting up a self-hosted farmOS that you can install your own module on to test against.
Once you have a module that works for your purposes, you can make it available to anyone running farmOS. If you want to make it available to Farmier users, you can propose the module for inclusion. I’d be happy to talk about that separately (via email? also happy to chat about partner hosting options if that would be useful) but first step is to create your module and make sure it works on any farmOS instance (not Farmier-specific).