1

I am trying to convert one of my web app to hybrid mobile app using cordova. I am using polymer and web components. I am able to render the UI in ios device also. However I want to know how to configure IP address and port of my server (my laptop in this case) dynamicallly when building or depolying the app. May be some cordova setting (like env variable or build argument)

my html

<html lang="en">

<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="styles/app-theme.html">
<link rel="import" href="bower_components/paper-toolbar/paper-toolbar.html">
<link rel="import" href="bower_components/paper-drawer-panel/paper-drawer-panel.html">

some ajax call.

<iron-ajax id="resetValidate" **url="/api/appusers/reset"** method="post" content-type="application/json" on-response="handleResponse" on-error="handleError"></iron-ajax>
....

So actually I want to call http::/192.168.1.39:3000//api/appusers/reset in this case, but changing code is not a good solution, as I have more than 100 places and more over this ip will be different for all developers and also it will change every time. When application will be ready obviously I will need to configure some baseurl for all apis also, so I want to know what is the way in cordova for this.

This works in web application / browser as I render the html and js files as well api from same express server. So hostname and port is same for static and dynamic content and is localhost during development.

  • as far as i know, usually the URL and port no. should be specified manually in some settings page in the cordova app (may be before logging on) and this can be stored in session or local storage for subsequent usage. – Gandhi Mar 18 '16 at 12:49
  • Most of apps will have predetermined server although some apps may provide changing of server. In my case it is not user of app who decides server it is app which is deciding the server. Only thing is I consider each developer's app as different app but these apps share source code that is why I am looking at some build time variable. – Praveen Kumar Gulati Mar 19 '16 at 03:58

0 Answers0