That is not possible with your current stack.
Your Heroku application and your S3 bucket are actually served through two different domains. The benefit of having two different domains is that you can offload your server from all static assets requests.
A convoluted way to achieve what you want would be to appropriately proxy the requests through one unique domain. Luckily for you neither Heroku nor Amazon will let you do that:
- Nginx could proxy a
static
folder toyour-api.herokuapp.com
but you cannot configure nginx on Heroku, that would defeat the purpose of using a PaaS in the first place. S3 can host your website and redirect an
api
folder toyour-api.herokuapp.com
but only with 301 redirects that don't solve CORS issues. Just tried it if you're curious:<RoutingRules> <RoutingRule> <Condition> <KeyPrefixEquals>api/</KeyPrefixEquals> </Condition> <Redirect> <HostName>your-api.herokuapp.com</HostName> </Redirect> </RoutingRule> </RoutingRules>
At that point the easy solution is to implement a Django middleware for cross-domain sharing.