I'm currently in the process of upgrading my app from v12 to v13 and noticed this warning pop up:
Option "deployUrl" is deprecated: Use "baseHref" option, "APP_BASE_HREF" DI token or a combination of both instead. For more information, see https://angular.io/guide/deployment#the-deploy-url.
After digging into it a little more, none of the 'baseHref' or APP_BASE_REF options really work for my setup so I'm wondering if I'm using them incorrectly or if there isn't a good way to go about replacing it
Here's a snippet of the app config from angular.json:
"dashboard": {
"projectType": "application",
"root": "apps/dashboard",
"sourceRoot": "apps/dashboard/src",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [],
"outputPath": "../dist/dashboard/",
"deployUrl": "/dist/dashboard/",
"index": "apps/dashboard/src/index.html",
"main": "apps/dashboard/src/main.ts",
"tsConfig": "apps/dashboard/tsconfig.app.json",
"polyfills": "apps/dashboard/src/polyfills.ts",
"styles": [
"apps/dashboard/src/styles.scss"
],
"scripts": [],
"stylePreprocessorOptions": {
"includePaths": [
"libs/assets/styles"
]
},
"aot": false,
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"optimization": false,
"namedChunks": true
},
"configurations": {
"production": {
"aot": true,
"buildOptimizer": true,
"extractLicenses": true,
"fileReplacements": [
{
"replace": "apps/dashboard/src/environments/environment.ts",
"with": "apps/dashboard/src/environments/environment.prod.ts"
}
],
"namedChunks": false,
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"vendorChunk": false
},
"es5": {
"tsConfig": "apps/dashboard/tsconfig.es5.json"
}
},
"defaultConfiguration": ""
}
}
}
Snippet of routing file:
export const DashboardRoutes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: '/dashboard' },
{
path: 'dashboard',
data: {
label: 'Dashboard',
appBase: true
},
children: [
// this is a child so we can load the component in same router-outlet
{
path: '',
loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule),
data: {
authorizedRoles: ['member'],
}
},
// ...other children
]
}
]
I've tried changing deployUrl to baseHref and that works, kind of - It changes the main page from localhost/dashboard
to localhost/dist/dashboard/dashboard
(obviously not right) and just putting an empty string or "/" doesn't load the app correctly (looks at dist/ vs dist/dashboard like it should)
Worth noting that my index.html does use <base href="/" />
and APP_BASE_HREF is not overridden in the app module providers
Ended up finding something to replace this with:
{ provide: APP_BASE_HREF, useValue: '/' }
<base href="/">