I have developed an angular 2 app and deployed it to a server that is running behind something like
http://localhost:8080/platform/owa/myapp/index.html
The platform is a Java application that has support for Open Web Apps via their Open Web App(OWA) module. So all apps deployed on the platform are always accessed from /platform/owa/app_name/index.html.
So when I first deployed my Angular 2 app, I had a lot of 404 errors, I looked at the console and noticed that all JavaScript files are being resolved from root. For example http://localhost:8080/script.js instead of http://localhost:8080/platform/owa/app_name/script.js. To fix this I had to set the base-href dynamically like this
document.write('<base href="' + document.location + '" />');
With that change I stopped getting 404 error messages and the pages could display fine. But an issue pops up in pages that need to access images in the /assets/ folder. The images don't display. My logo could not display and when I checked the console I noticed that angular is still trying to resolve the assets folder with respect to root like
localhost:8080/assets/logo.png and that causes 404 and my logo can't display. I'm also using tinymce editor in my project and it expects some files to be present in the /assets/ folder but since it can't access the assets folder too the tinymce editor does not work.
Update Based on the comment below, I realized I left one important detail. To access my logo I used I set the source to /assets/logo.png. Maybe I can change that to use the path of the application since it's under my control but how do I make tinymce resolve the assets folder. It's a plugin I downloaded and it expects some files to be in the assets folder.