Forum Discussion

Baradanikto's avatar
Baradanikto
Roku Guru
10 years ago

Localhost as Server?

I've started to develop my first channel and I've based it off one of the examples. In going through the sample code, I noticed references to resources on Roku servers. I plan to set up my own server on a hosting site, but, I don't' have one at the moment. I do, however, have an Apache localhost server that I use for other development. Is it possible to develop my channel using my localhost server? I'd like to write the code so that when I'm finished, all I need to do is change the urls to point to my live server. If it is possible, what functions, classes, etc. should I pay attention to?

4 Replies

  • Yes, it's definitely possible to develop your channel using an Apache server on your local network. When you specify a url in your Roku code, the Roku doesn't care where the resource is located, whether it's on the local network, or a remote host. It's more a function of your network's router to route the requests to your local server. How you do it depends on your particular router.

    In my case, my router has a "DNS Host Mapping" feature that allows me to associate an IP address on my local network with a domain name, so that any requests from a device on the local network (e.g. my Roku) for the specified domain name (e.g. mydomain.com) will be directed to a specified IP address (the IP address of my laptop, e.g. 192.168.0.42). I need to ensure that my laptop's firewall allows the request, and that the server is configured to handle requests for that domain.
  • maybe obvious but ideally you set the base URL to a global variable and use that variable everywhere you make an API call - then when you're ready to change it, you only need to change it in that one place.
  • I like belltown's approach because does not introduce extra abstraction and can be used for testing of even already signed bundle. That said, requires a router that can do the DNS re-directs.

    If using app-configurable variable, here is one bonus idea: roAppInfo.getValue() can be used to fetch the base URL from the manifest (i.e. take that out from the code). Is that BFD... eh, not really.
  • Thanks for all the replies.  I found a much easier approach.  I have a Synology NAS that allows me to set up web sites.  I built a test web site on the NAS and loaded up some videos.  I then pointed my code to the NAS web site and I am able to test.  This, for me, is a better approach than using localhost as I had originally asked.

    Thanks again.