0

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.

Rohan Khajuria
  • 636
  • 2
  • 12
  • 26
  • 1
    Does this answer your question? [Webpack Code Splitting 'Loading chunk failed' error wrong file path](https://stackoverflow.com/questions/53704950/webpack-code-splitting-loading-chunk-failed-error-wrong-file-path) – ihor.eth Apr 08 '20 at 05:19
  • Yup, thanks! If you post it as as an answer I'll accept it. – Rohan Khajuria Apr 12 '20 at 04:51

0 Answers0