Basing on How to run Ionic serve permanently? and Deploy Ionic as a website, nginx should be able to serve the code from the Ionic's www folder. I am exploiting the idea of serving it with its Rails back-end together using the same domain address... so that no CORS traffic and overhead will be added. Another requirement for the Rails WEB is to still handle the desktop (HTML) version of the website. Essentially, there will be 3 types of requests coming to the nginx server:
- loading html, js, css files from the mobile/www/ directory
- mobile website and APP JSON calls to Rails API
- desktop website HTML calls to Rails
Type 2 requests may be simple because they all have the .json extension. With sub-domains are taken by the username, i.e. username.example.com, any ideas on how to have nginx route the html, js, and css requests correctly? Or is this too much of a challenge?
Take #1: Come up with a Nginx config that returns Ionic files when Rails signals it in a hidden manner. May be clumsy, so please feel free to offer criticism, pitfalls, or improvements.
Nginx config:
In RoR:
Two birds with one APP :).