I'm currently creating a website in Django and Angular. Django is serving the Angular build files. Excluding /api
calls, all URLs are returned a template that loads the Angular index. This part works.
The part I'm having trouble with is when I try to lazy-load modules. Angular will try to find a module foo
at localhost:8000/foo-module.js
, but it's really at localhost:8000/static/mydjangoapp/angular/foo-module.js
.
I know I could solve this problem by setting <base href="/" />
in index.html
to <base href="/static/mydjangoapp/angular" />
, but I want the frontend to be served from /
. I could also avoid lazy-loading modules, but I feel like there's a better way to serve Angular from Django using which I can lazy-load.
How can I get Angular to properly fetch the URLs? I'm also having a similar issue with serving Angular assets.