react-redux-starter-kit
react-redux-starter-kit copied to clipboard
Async module loading of protected assets: how?
Hey guys, huge thanks for this starter kit. I apologize if this is the wrong place to ask, I realize this question is not directly related to the stuff this repo is about.
So, my problem is that our API protects not just API endpoints, but assets as well, for various reasons which are off topic. Basically, all requests to assets (css, favicon, js bundles) need to contain the auth token. I'm setting up split points at route level for the main user roles; the bundle names contain data that helps the API to asociate bundles with user roles. E.g. admin.dashboard.js vs user.dashboard.js.
How can I hijack require.ensure to include a jwt in the request headers when it loads a chunk? Also, is there a way to handle a 401 response? I was trying to find documentation on how require.ensure works, but could not find anything. I believe this guy is facing the same problem, no body seems to know how to do this.
Many thanks :)