Angular 13 - What replaces DeployURL

Viewed 1867

I've just upgraded a project to angular 13, and it removed my "deployUrl" option under serve. What's replacing this ?

For context my prod deployments are under a path (/appname/) so I have that in the deployUrl for build, but that's a bit annoying when using ng serve during development so I was using a different deployUrl (just /) in serve.

Without it I have to use localhost:4200/appname/ when using ng serve, which isn't the end of the world but a bit annoying.

Thanks

2 Answers

From Angular official docs, it doesn't sound like deployURL was removed in v13 but it may be removed in v15:

Use baseHref option, APP_BASE_HREF DI token or a combination of both instead. For more information, see the deploy url.

In the end my solution was to replace my deployUrl with a servePath in angular.json :

        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "console:build",
            "proxyConfig": "proxy.conf.json"
          },
          "configurations": {
            "dev": {
              "browserTarget": "console:build:dev",
              "servePath": "/"
            }

Then I added what used to be my deploy url as a proxied path in proxy.conf.json :

{
    "/mypath/*": {
      "target": "http://localhost:4200/",
      "pathRewrite": {"^/mypath" : ""}
    }
  }

With this I got back the same behavior when using serve : my prod is still deployed under /mypath, but my local serve instance still works directly on /. I'll have to figure something for build before they remove deployUrl there, but baseHref might do, I need to test it out.

Related