Is possible to use Capacitor/Ionic with serveless functions (like Netlify Functions)?

Hi everyone!

Has anyone ever tried port a React web app on Serverless (using Netlify Functions) to a mobile app using Ionic/Capacitor?

I am trying this now, but the requests to the serverless functions just don’t work. I wonder if they are compatible at all.

If it is possible, is there any doc or tutorial guiding on to configure it?
Right now, I can make my project build and run on an Android emulator, but every request to my serverless functions are not actually processed by the functions and just return an HTML response.

I am using Netlify Functions, which are built in a /functions/ folder that it’s not included in the /build folder. I assume there is no server running in the app too. So the requests to endpoints like http://localhost/.netlify/functions/users-login return an HTML, not the expected processed JSON.

Any clues?

Isn’t a call to a serverless function just a regular HTTP request? If so, it should work in the same way as you can make any HTTP request from your Ionic/Capacitor app.

How do you run a “serverless” function on localhost? Is that some kind of special dev server provided by the Netlify tools for local development?

I would guess that if you deploy your functions, so they have a public URL rather than localhost, then you should be able to call them from your Ionic app.

Yes, when I build my non-ionic version, I build both the app and the server, which uses the package netlify-lambda to create a local server for the functions. I believe Ionic execution is not running this script. I am new to Ionic and not sure why and how to make it run (the script is included in my npm start script).