Reputation: 4429
Ok, basically I'm using Nginx, Passenger, Rails and Angular. I've created an Angular app that compiles to Rails' public folder. Rails provides the API underneath the Angular app.
I'd like to have all traffic that comes www.mydomain.com/admin
to this admin.html
file located in the public directory. I've got a route in Rails config/routes.rb
pointing to admin.html
like so:
match '/admin/*all' => redirect("/admin.html"), via: 'get'
But that doesn't seem to do the trick. I also would like Nginx to redirect all traffic with admin/*
to this admin.html
file in public folder.
By the way, the admin.html
is the Angular app.
EDIT: The Angular app is not being served by Rails
At the moment, there's no views in Rails at all. Rails is just an API underneath a standalone Angular app that happens to be in the public directory inside Rails app. I've chosen this approach at this stage for two reasons: One I might deploy the Angular on a separate server at later stage, but not right now. So keeping the Angular completely independent and separate is a good idea. Two, At the moment, keeping the Angular on top of the Rails app will help reduce latency.
The whole setup is part of an experience that will evolve, I wanted to keep my options open moving forward.
Upvotes: 1
Views: 469
Reputation: 2349
Add a route to an action that loads the angular application, then have your normal resources (probably APIs) in the routes.rb
afterwards
routes.rb
match 'admin', to: 'admin#angular', via: :all
admin_controller.rb
def angular
render 'layouts/admin'
end
Then layouts/admin.html.haml
is your Angular application
Reference: https://thinkster.io/angular-rails/ (very good tutorial btw)
Upvotes: 3