# Different environments for my application

**URL:** <https://forum.ionicframework.com/t/different-environments-for-my-application/15705>\
**Category:** ionic-v1\
**Created:** [January 14, 2015, 8:57pm UTC](https://forum.ionicframework.com/t/different-environments-for-my-application/15705 "2015-01-14T20:57:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesquivel91](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jesquivel91](https://forum.ionicframework.com/u/jesquivel91)\
**Post date:** [January 14, 2015, 8:57pm UTC](https://forum.ionicframework.com/t/different-environments-for-my-application/15705/1 "2015-01-14T20:57:49Z")

</div>

Hi, I have been trying to figure it out. How to is it possible to build different environments for my application.

When In production I want the app to hit one URL and when development the app should hit other URL.

Thank you for your.

---

<div class="post-metadata">

**Author:** ![CyberFerret](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/cyberferret/32/72111_2.png) [@CyberFerret](https://forum.ionicframework.com/u/CyberFerret)\
**Post date:** [January 14, 2015, 11:09pm UTC](https://forum.ionicframework.com/t/different-environments-for-my-application/15705/2 "2015-01-14T23:09:49Z")

</div>

Is this a data access URL within your app ?

It would be nice if Ionic could support a similar sort of workflow to, say, Ruby on Rails whereby we can nominate a development, test and production environments with the associated data pointers and global variables etc.

But in the interim, I manage to hack through this via checking the `ionic.Platform.device()` object to see if I am running in a web browser (development) or the device (production). An empty object being returned means we are running in a browser (i.e. during development):

```
if (angular.equals({}, ionic.Platform.device())) {
  // development declarations go here 
} else {
  // production declarations go here
}
```

---

<div class="post-metadata">

**Author:** ![jesquivel91](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jesquivel91](https://forum.ionicframework.com/u/jesquivel91)\
**Post date:** [January 14, 2015, 11:14pm UTC](https://forum.ionicframework.com/t/different-environments-for-my-application/15705/3 "2015-01-14T23:14:15Z")

</div>

That’s actually a pretty nice hack. It would be nice if they could support enviorments right from the start.

Thank you.

---

<div class="post-metadata">

**Author:** ![pcr](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/pcr/32/6928_2.png) [@pcr](https://forum.ionicframework.com/u/pcr)\
**Post date:** [January 15, 2015, 12:41am UTC](https://forum.ionicframework.com/t/different-environments-for-my-application/15705/4 "2015-01-15T00:41:00Z")

</div>

I check the $host in the $location where the app is running on. Depending on the $host I change the Url I use in my code. If the app is running on a desktop browser there is a $host. Like in my development environment its localhost from the URL [http://localhost/appname](http://localhost/appname).  
If the app is running on a mobile device there is no $host. So I use a default Url for where a mobile app is pointing to and overruled by the $host if there is one in $location. Hope this helps…

---

<div class="post-metadata">

**Author:** ![jesquivel91](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jesquivel91](https://forum.ionicframework.com/u/jesquivel91)\
**Post date:** [January 15, 2015, 6:14am UTC](https://forum.ionicframework.com/t/different-environments-for-my-application/15705/5 "2015-01-15T06:14:23Z")

</div>

Thank you, I think both solutions are pretty great, that’s what I needed.
