Skip to content
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

Angular 17: getting Internal server error: Invalid URL error when starting dev server #27327

Closed
1 task done
harshpatel147 opened this issue Mar 21, 2024 · 1 comment · Fixed by #27330
Closed
1 task done
Assignees
Labels
devkit/build-angular:dev-server freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix

Comments

@harshpatel147
Copy link

harshpatel147 commented Mar 21, 2024

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Description

today I installed the angular 17 with SSR. after installation when I run ng serve --project my-app --host x.x.x.x --port 4200 for start dev server. dev server starting on given host port. but when I open url in browser then I'm getting following error.

1:03:41 PM [vite] Internal server error: Invalid URL
      at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
      at new NodeError (node:internal/errors:405:5)
      at new URL (node:internal/url:676:13)
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:164:36
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:203:47

If I start dev server on localhost ng serve --project my-app & run url in browser then work charm. this above issue face only when starting the dev server on IP

you can see below full console log of dev server

ng serve --project my-app --host x.x.x.x --port 4200

Warning: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disable-host-check" if that's the
case.
    
Browser bundles        
Initial chunk files     | Names               |  Raw size
polyfills.js            | polyfills           |  83.60 kB | 
main.js                 | main                |  22.22 kB | 
styles.css              | styles              | 118 bytes | 

                        | Initial total       | 105.93 kB


Server bundles         
Initial chunk files     | Names               |  Raw size
chunk-V6QZVQ3I.mjs      | -                   |   1.70 MB | 
polyfills.server.mjs    | polyfills.server    | 555.05 kB | 
main.server.mjs         | main.server         | 215.13 kB | 
chunk-VPSODEBW.mjs      | -                   |   2.51 kB | 
render-utils.server.mjs | render-utils.server | 423 bytes | 

Lazy chunk files        | Names               |  Raw size
chunk-OTT6LQ5K.mjs      | xhr2                |  39.10 kB | 

Application bundle generation complete. [4.464 seconds]

Watch mode enabled. Watching for file changes...
Re-optimizing dependencies because lockfile has changed
  ➜  Network: http://x.x.x.x:4200/
  ➜  press h + enter to show help
1:03:41 PM [vite] Internal server error: Invalid URL
      at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
      at new NodeError (node:internal/errors:405:5)
      at new URL (node:internal/url:676:13)
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:164:36
      at /var/www/html/angularProjects/microtech-restaurant-web/node_modules/@angular-devkit/build-angular/src/tools/vite/angular-memory-plugin.js:203:47

Minimal Reproduction

ng generate application ordering-app
? Would you like to share pseudonymous usage data about this project with the Angular Team
at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more
details and how to change this setting, see https://angular.io/analytics. No
Global setting: enabled
Local setting: disabled
Effective status: disabled
? Which stylesheet format would you like to use? Sass (SCSS)     [ https://sass-lang.com/documentation/syntax#scss                ]
? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? Yes

Exception or Error

No response

Your Environment

ng v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.3.1
Node: 18.19.1
Package Manager: npm 10.2.4
OS: linux x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1703.1 (cli-only)
@angular-devkit/core         17.3.1 (cli-only)
@angular-devkit/schematics   17.3.1 (cli-only)
@schematics/angular          17.3.1 (cli-only)

Anything else relevant?

No response

@alan-agius4 alan-agius4 self-assigned this Mar 21, 2024
@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity3: broken devkit/build-angular:dev-server labels Mar 21, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Mar 21, 2024
…RL` when using a non localhost IP

When using a non-localhost IP, Vite will correctly populate the `network` property of the `server.resolvedUrls` instead of `local`.

Example:
```
ng server --host=127.0.0.2
{ local: [], network: [ 'http://127.0.0.2:4200/' ] }
```

Closes angular#27327
clydin pushed a commit that referenced this issue Mar 21, 2024
…RL` when using a non localhost IP

When using a non-localhost IP, Vite will correctly populate the `network` property of the `server.resolvedUrls` instead of `local`.

Example:
```
ng server --host=127.0.0.2
{ local: [], network: [ 'http://127.0.0.2:4200/' ] }
```

Closes #27327
clydin pushed a commit that referenced this issue Mar 21, 2024
…RL` when using a non localhost IP

When using a non-localhost IP, Vite will correctly populate the `network` property of the `server.resolvedUrls` instead of `local`.

Example:
```
ng server --host=127.0.0.2
{ local: [], network: [ 'http://127.0.0.2:4200/' ] }
```

Closes #27327

(cherry picked from commit ee9ec23)
@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 Apr 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
devkit/build-angular:dev-server freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
2 participants