We are deploying Angular 16.1.0 app behind an application proxy and we face some issues.
angular.json
/projects/app/architect/build/options/baseHref
"baseHref": "/app/context/",
But when we build the app, it does not follow the configuration and generates:
<script src="runtime.js" type="module"></script>
<script src="polyfills.js" type="module"></script>
<script src="vendor.js" type="module"></script>
<script src="main.js" type="module"></script>
Instead of
<script src="/app/context/runtime.js" type="module"></script>
<script src="/app/context/polyfills.js" type="module"></script>
<script src="/app/context/vendor.js" type="module"></script>
<script src="/app/context/main.js" type="module"></script>
So these files were not found. We fixed it with post build script, but I consider it as a hack and I would like to fix this issue.
Second issue is with a loaded javascript in a webpack bundle. Routes.ts is using relative paths:
export const APP_ROUTES: Routes = [
{
path: '',
loadComponent: () =>
import('./documents/components/document-home/document-home.component').then(m => m.DocumentHomeComponent),
},
This generates the file:
const APP_ROUTES = [{
path: '',
loadComponent: () => __webpack_require__.e(/*! import() */ "src_app_documents_components_document-home_document-home_component_ts").then(__webpack_require__.bind(__webpack_require__, /*! ./documents/components/document-home/document-home.component */ 95501)).then(m => m.DocumentHomeComponent)
With a relative path starting with .documents/
instead of the prefix /app/context/documents/
.
And then this file is not found again and the app crashes. The file is a standalone file in home directory, not part of webpack bundle. How can I fix this issue?