Open jwalton opened 4 years ago
Interestingly, curl --head -k https://127.0.0.1:8080/login
returns a 404. I wonder if axios is secretly doing a HEAD before it does the GET?
Same issue on a health check handler
wait-on by default does a HEAD request since that is idempotent. GET's are also supposed to be idempotent but sometimes the user implementation performs side effects.
In an ideal world you should always be able to make HEAD requests to a server if it is implemented properly so I am surprised when server implementations do not implement the HEAD method, it makes no sense to me.
Anyway if you need to do a GET request instead, change the URL to http-get://127.0.0.1:8080/login
or for TLS https-get://127.0.0.1:8080/login
Your command would look like
npx wait-on https-get://127.0.0.1:8080/login
As noted in my bug report above, this is exactly what I'm doing:
npm-run wait-on -v https-get://127.0.0.1:8080/login
sorry @jwalton I misread your comments above. Maybe axios is doing a HEAD request pre-flight or something. Previously we used request until it was no longer supported, so there are some differences between it and axios and maybe this is one of them. I will see if there is an option we can pass to skip that.
Missed that. Unfortunately, I don't own the service I'm making the health check to so I can't update it to accept HEAD requests. Prefacing with http-get:
fixed my issue. Thank you!
I'm also having this problem with a Vite dev server. I see the same results ("Request failed with status code 404") regardless of whether I use http
or http-get
:
wait-on --verbose http-get://localhost:3030/
In other tools, requesting the same URL gives a 200 OK, although HEAD does return a 404.
For now, a workaround would be using validateStatus
in wait-on's configuration and make 404 a valid status code.
validateStatus: (status) => {
return (200 <= status && status < 300) || status === 404
}
I was getting a 404 when using Vite, not Webpack, but the solution I found might work for you too;
GET
not HEAD
, i.e. use https-get:
.accept: text/html
header.You need a config file to send a header; waitOnConfig.json
:
{
"headers": {
"accept": "text/html"
}
}
wait-on -c waitOnConfig.json https-get://localhost:3001
I'll see if I can find anything this weekend.
On Thu, Jun 24, 2021 at 12:16 PM Adam Lynch @.***> wrote:
I was getting a 404 when using Vite, not Webpack, but the solution I found might work for you too;
- Use GET not HEAD, i.e. use https-get:.
- Send an accept: text/html header.
You need a config file to send a header; waitOnConfig.json:
{ "headers": { "accept": "text/html" } }
wait-on -c waitOnConfig.json https-get://localhost:3001
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jeffbski/wait-on/issues/78#issuecomment-867813529, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABMOOV67JZVEEGJX4OQI3TUNR6HANCNFSM4QH35UGQ .
-- Jeff Barczewski Founder of CodeWinds http://codewinds.com/ Live and Online developer training
I'm also having this problem with a Vite dev server. I see the same results ("Request failed with status code 404") regardless of whether I use
http
orhttp-get
:
wait-on --verbose http-get://localhost:3030/
In other tools, requesting the same URL gives a 200 OK, although HEAD does return a 404.
wait-on tcp:3030
Thanks for the tips @xkim1994 , it works well! (using Vite here).
Why would Vite return a 404 for Accept: */*
-.-", probably a bug https://github.com/vitejs/vite/issues/9520
I have a webpack-dev-server running in HTTPS mode:
wait-on
will correctly tell me the URL is up with no path:passes no problem, but it fails for /login:
But curl gets a 200 OK:
And
cross-fetch
finds it fine, too: