Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 15 tasks
i3ene opened this issue Apr 11, 2022 · 5 comments · Fixed by #22970 or #22971
Closed
1 of 15 tasks

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

i3ene opened this issue Apr 11, 2022 · 5 comments · Fixed by #22970 or #22971
Assignees
Labels
Milestone

Comments

@i3ene
Copy link

i3ene commented Apr 11, 2022

🐞 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]
@alan-agius4
Copy link
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'

@i3ene
Copy link
Author

i3ene commented Apr 11, 2022

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

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Apr 11, 2022

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

@i3ene
Copy link
Author

i3ene commented Apr 11, 2022

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.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants