0

I'm building web app with an angular.js/django frontend backend and I was wondering if it's possible to configure AWS to return a static html file for all url's except for my api calls. For example:

http://somewebsite.com/(non-api path)/ <- returns static.html
http://somewebsite.com/api/(path)/ <- returns the response from the api

The ultimate goal would be to allow static.html to be completely separate from the Apache server on EC2 running the django api and instead allow it to be uploaded to the S3 instance along with my other static files.

  • May be helpful: https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/ – jarmod Jun 05 '15 at 19:19
  • Do you mean a *single* static file regardless of the URL? (That's what it sounds like). If so, what about your other assets? Are they on the same domain, or a different one? – Michael - sqlbot Jun 06 '15 at 00:07

2 Answers2

0

If you configure your s3 bucket for website hosting you should be able to define redirect rules from one page to another. See : http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html

However, probably the simplest solution would be to have a catch all url rule in your django app and either return a HttpResponseRedirect to your static page or proxy it through the application. Hope this helps.

chaos
  • 480
  • 3
  • 8
  • Yeah I currently have a catch all rule in my django app but I was hoping for a more efficient version for production. Thanks for the link though, I will check it out. –  Jun 05 '15 at 17:35
0

After looking at this question I discovered that you can redirect all responses to return the index.html page.

From that point you can purchase a second domain or create a subdomain to route your api separately from your front end.

Community
  • 1
  • 1