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

HTTP HEAD request results in 404 #924

Closed
reiner-dolp opened this issue May 28, 2017 · 7 comments
Closed

HTTP HEAD request results in 404 #924

reiner-dolp opened this issue May 28, 2017 · 7 comments

Comments

@reiner-dolp
Copy link

reiner-dolp commented May 28, 2017

Do you want to request a feature or report a bug?
Bug.

What is the current behavior?
HTTP HEAD method requests result in a 404: Not Found even though the resource exists and is retrievable using HTTP GET.

If the current behavior is a bug, please provide the steps to reproduce.
Compile using webpack and request any file:

$> curl -I http://localhost:8080/index.html 
HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Security-Policy: default-src 'self'
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 158
Date: Sun, 28 May 2017 09:35:14 GMT
Connection: keep-alive
$> curl -G http://localhost:8080/index.html
<h1>works</h1>

Please mention your webpack and Operating System version.
Tested on Windows 10 with dev server 2.4.5 and webpack 2.6.1

@Opty1712
Copy link

Opty1712 commented Jul 7, 2017

you can go with this code of proxy:

'/my_url/**': {
  target: config.targetLocal,
  bypass: (req) => {
    req.method = 'GET'; 
  },
},

@shellscape
Copy link
Contributor

You can use the proxy method, or you'll have to extend the middleware to handle HEAD requests. At present it only supports GET. You can view some of the setup for that here. I think this would be a little too edge case to make it a permanent part of WDS.

@alzuma
Copy link

alzuma commented Dec 5, 2018

Why this is closed? It is a normal use case to check etag with HEAD request. This req.method = 'GET'; is just unneeded hacking.

@sindresorhus
Copy link

sindresorhus commented Jan 11, 2019

@shellscape It's also a common use-case to use a HEAD request to check whether the server is running. Can you please reopen?

Example: https://github.com/sindresorhus/wait-for-localhost/blob/master/index.js

@Jaans
Copy link

Jaans commented Mar 21, 2019

+1 Please add support for HEAD method requests as it is a common HTTP Method to use instead of GET when only the headers are needed.

@HenriqueLimas
Copy link

Also critical is using method HEAD for checking if the css file exists: https://github.com/addyosmani/critical/blob/master/src/file.js#L115

FYI @addyosmani @bezoerb

@sindresorhus
Copy link

Continued in #1833.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants