Skip to content

HEAD requests return 404 on Angular 18 dev server (except for index.html) #28376

@jonathan-valle

Description

@jonathan-valle

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Don't known

Description

When sending a HEAD request to the Angular 18 development server (with vite), it returns a 404 response for all files except for index.html. However, GET requests to the same files return a 200 response.

Please provide a link to a minimal reproduction of the bug

Start the development server with Angular 18 (with vite).

Please provide the exception or error you saw

Steps to Reproduce:
Start the development server with Angular 18 (with vite).

Make a GET request for a file, such as main.js:

curl -vvv http://localhost:4200/main.js
Response: 200 OK

Output
* Connected to localhost (::1) port 4200
> GET /main.js HTTP/1.1
> Host: localhost:4200
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: text/javascript
< Cache-Control: no-cache
< Etag: W/"5b40-oerrD+AKotT2Cte2dRk3u8TLupI"
< Date: Mon, 09 Sep 2024 11:28:24 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 58235

Make a HEAD request for the same file:

curl -I -vvv http://localhost:4200/main.js
Response: 404 Not Found

Output:
* Connected to localhost (::1) port 4200
> HEAD /main.js HTTP/1.1
> Host: localhost:4200
> User-Agent: curl/8.7.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 404 Not Found
< Access-Control-Allow-Origin: *
< Content-Security-Policy: default-src 'none'
< X-Content-Type-Options: nosniff
< Content-Type: text/html; charset=utf-8
< Content-Length: 147
< Date: Mon, 09 Sep 2024 11:27:55 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 18.2.3
Node: 20.16.0
Package Manager: npm 10.8.1
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1802.3 (cli-only)
@angular-devkit/core         18.2.3 (cli-only)
@angular-devkit/schematics   18.2.3 (cli-only)
@schematics/angular          18.2.3 (cli-only)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions