Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert node.js application into cordova

we built a node.js application for desktop and tablet. It's completely web based application. Now I am planning to implement same application as native app in android using Apache cordova.

Under project directory, we have node_modules,public,.... all client side files are in public folder. When I invoke URL in browser, from client side I am making API call to check whether user already logged or not. like this we are making API calls to my server.

As per my understanding,native app is nothing but we are storing all the client side files into device. whenever user open app will load client side files and as per work flow it will make API calls.

Theoretically I understand that much.

where I stuck :

In desktop app , I used to make API calls with URL like /api/web/shared/reject/, here we don't need to mention server address like localhost:8080/api/web/shared/reject/ that everything browser will take care. This same thing how can I make it work in cordova applications.

How cordova will know whether it is localhost or something else...

Regarding this, I Goggled but I didn't find any tutorials.

can anyone suggest me the way.

like image 620
vasan Avatar asked Oct 31 '22 16:10

vasan


1 Answers

Basically, is a concept problem. Node.js is a technology specialised in backend and some of usages like extend some services/functions, etc. When you talk of a localhost:8080 you are talking that your node.js implementation should be in a server (Amazon, Azure, your own server, nodejitsu, etc), and the public pages or the pages that the client should consume will be added into phonegap, specifically in your www directory and the references for localhost:8080 should be changed for your server (Amazon, your own server, nodejitsu, etc), and the files on your www directory could have references (via GET or POST to retrieve the data from the server. Remember, the Crossdomain problem doesn't happens on phonegap (maybe in a local enviroment should occur). And Phonegap is a framework to develop front-end with HTML5, jquery, CSS3 and other releated technologies. For your specific case the node_modules should be installed in the server too, not on the phonegap project.

like image 150
Benjamin RD Avatar answered Nov 09 '22 09:11

Benjamin RD