Skip to content

Dev-server error after setting proxy.conf.json loglevel to "verbose" #22969

Description

@i3ene

🐞 Bug report

Command

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: Angular v12

Description

As of the new WebPack version in Angular v13 I changed the logLevel inside my proxy.conf.json from debug to verbose.
Since then I receive on ng serve:

An unhandled exception occured: Dev-server address info is not defined.

To Note

I work inside an Angular "workspace", so my apps are inside the "projects" folder.

Also (when I remove logLevel, so that the Dev-Server starts) I receive duplicate requests on my API end.
Some of my URLs go to /api/proxy/my-service and after WebPack proxy it should look like http://localhost:3005/proxy/my-service. But I also receive a second request on http://localhost:3005/my-service? Does it have a problem with the keyword "proxy" inside URLs?

🔬 Minimal Reproduction

  1. Create a new workspace with ng new my-workspace --create-application false
  2. Inside this workspace, create new app with ng generate application my-first-app
  3. Inside this application C://.../my-workspace/projects/my-first-app create a proxy.conf.json with something like
{
  "/api/*": {
    "pathRewrite": {"^/api": ""},
    "target": "http://localhost:3005",
    "logLevel": "verbose"
  }
}
  1. Inside workspace, add to angular.json:
{
 ...
 "projects": {
  ...
  "my-first-app": {
   ...
   "serve": {
    ...
    "options": {
            "proxyConfig": "projects/my-first-app/proxy.conf.json"
    },
    ...
   }
  ...
  }
 ...
 }
...
}
  1. Run ng serve my-first-app and observe

🔥 Exception or Error


[error] Error: Dev-server address info is not defined.
    at C:\Users\...\my-workspace\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:63:27

🌍 Your Environment


Angular CLI: 13.3.2
Node: 16.14.2
Package Manager: npm 8.5.0
OS: win32 x64

Angular: 13.3.2
... animations, cdk, cli, common, compiler, compiler-cli, core    
... forms, material, platform-browser, platform-browser-dynamic   
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.2
@angular-devkit/build-angular   13.3.2
@angular-devkit/core            13.3.2
@angular-devkit/schematics      13.3.2
@angular/flex-layout            13.0.0-beta.38
@schematics/angular             13.3.2
ng-packagr                      13.3.0
rxjs                            7.5.5
typescript                      4.6.3

Output of npm ls webpack-dev-server:


[email protected] C:\Users\...\my-workspace
└─┬ @angular-devkit/[email protected]
  ├─┬ @angular-devkit/[email protected]
  │ └── [email protected] deduped
  └── [email protected]

Activity

  1. alan-agius4 commented on Apr 11, 2022

    @alan-agius4
    Collaborator

    I looks like we are not emitting proxy config errors.

    verbose is not a valid value for logLevel .

    https://github.com/chimurai/http-proxy-middleware#options

    option.logLevel: string, ['debug', 'info', 'warn', 'error', 'silent']. Default: 'info'

  2. modified the milestone: Backlog on Apr 11, 2022
  3. self-assigned this
    on Apr 11, 2022
  4. i3ene commented on Apr 11, 2022

    @i3ene
    Author

    Argh, sorry, my bad.
    But it seems there is another issue (in general) with logging of proxy? Since "logLevel": "debug" doesn't log anything in console. Not even with ng serve my-first-app --verbose

  5. alan-agius4 commented on Apr 11, 2022

    @alan-agius4
    Collaborator

    I do see the logs from http-proxy-middleware being printed correctly.

    <i> [webpack-dev-server] [HPM] Proxy created: /api  -> http://localhost:3005
    <i> [webpack-dev-server] [HPM] Proxy rewrite rule created: "^/api" ~> ""
    

    Edit: I see that debug logs are not displayed because we never turn on https://webpack.js.org/configuration/other-options/#debug

  6. i3ene commented on Apr 11, 2022

    @i3ene
    Author

    Yeah, I wondered, because I also saw it being set up but did not see the active proxy output.

    Edit: I see that debug logs are not displayed because we never turn on https://webpack.js.org/configuration/other-options/#debug

    That's where I got verbose from, was a little lost when I looked into webpack.

  7. added 2 commits that reference this issue on Apr 11, 2022
    3afd1ab
    5682bae
  8. angular-automatic-lock-bot commented on May 12, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  9. locked and limited conversation to collaborators on May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: @angular-devkit/build-webpackfreq1: lowseverity3: brokentype: bug/fix

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions