What strategy could I use to deploy a SPA with basic page sitting in front

794 views Asked by At

Up until recently, I've been hosting my dev app on a single heroku instance. The API and the angular app are hosted from the same Express.js server. Along with a front-facing sales page, separate from the angular app, sitting at the base domain. It's time for production, so I need to split the two into the api server and any other service to host the static pages.

My Current Setup all on an express.js server

  1. mydomain.com --> Sales Page, static simple page with bower deps
  2. mydomain.com/api --> api
  3. mydomain.com/anything else --> Angular App
  4. mydomain.com/assets -> images and misc files

I would love to use a service like Amazon S3, Cloudfront, or Divshot to host #1, #3, and #4 on a CDN service. And keep the API (#2) on Heroku or AWS ec2.

Right now, my only thought is that I'd have to run a separate server myself and host the static files with Nginx, apache, or express.js to allow for the routing based on url because as far as I can find, the CDN services don't allow for .htaccess redirecting and such.

Thank you for the time.

1

There are 1 answers

0
Froyke On BEST ANSWER

To simplify, you only have 2 categories here:

  • Static: Sales, Angular, Assets
  • Dynamic: API

You should consider exposing all your static assets under mydomain.com/* hosted from whatever CDN, and have the dynamic stuff being served from your (probably AWS) instance @ api.mydomain.com

It is not the exact layout that you had in mind, but that one is trivial to setup.

The only minor addition here, is that you might need to setup CORS due to the double domains.