Issue
I discovered Ionic this week and I'm really considering using it at work.
My goal is to build an app that will work on Android and iOS, where the needed functionality is to connect to the cloud over web socket and pull data from the cloud and show it on my phone. Maybe later I'll eventually need to consider using login but not for now at least.
Normally, if I'm building a web app. I'll use Node.js to pull the data from the cloud and expose it to the frontend. I'll write all code together and I'll host my app in Heroku or something where the entry point is my Node.js server right? So that my server needs to start and it will take care of the rest.
This is a bit confusing in Ionic since I need to start the app with ionic serve
, but somehow I also need to start my Node.js server too right? So I assume I can't write the server-side code inside the ionic app or am I wrong?
There is not much about this on the internet but I did some research and I guess that I should deploy (host) my Node.js server in the cloud (maybe using Heroku) and then connect to the server from my mobile app over the socket. Is this the right/only way to do this? are there any security issues with this method?
I find ionic great but I'm not sure if I should use it at work. This use case of using a backend server with Ionic made me confused.
Ionic looks ideal for building cross-platform apps that does not need server-side scripting, but how complex can it be if I want to integrate some server-side code in my app? especially as I said I'm going to use some login forms in the future to extend the functionality of my app.
PS: I'm using Ionic 6.10.1 and specifically I'm interested in using ionic with React not with Angular.
Solution
After some search, I discovered that it isn't possible to deploy the frontend and backend code together. Therefore the trick is to deploy the nodejs server separate from the frontend.
Precisely, if it is a web app, then you should deploy the nodejs server in a separate host from the frontend. Then by starting the frontend app, you can communicate with the running nodejs server via socket or REST API.
Hope this helps someone in the future :)
Answered By - basilisk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.