-
Notifications
You must be signed in to change notification settings - Fork 245
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
"Cannot set headers..." error happening only on one specific kind of request #207
Comments
I tried this via Postman (don't know how accurate my approach is) but on Let me try with node 10.1.0 Even with 10.1.0, I am not getting that error thrown. Even with node-static v0.7.1 and v0.7.2 I am not getting error thrown. What am I missing?
No error |
I know, I've tried the same kind of thing and I'm not able to reproduce with those headers either. Super frustrating. I figure it must be:
Is there some way to turn on some kind of verbose logging of everything that happens when a connect/request comes in? I have no idea how to track this down other than what I've already tried. |
As implied by the code I pasted, I assume you are using a Also, it may help to forcibly set |
I think I read something about A valid 404 from all possible code path means that code is not throwing error. Regrading verbose logging, I sprinkled console.log in node-static. Other than that, verbose logging should be supported by modules, which node-static doesn't; at least not in installed version. May be dev version has more logging. MAY BE. Viel Glück! |
That's true, but it's also possible those kinds of requests/responses are going through different code paths inside node-static than regular found resources, since ostensibly it needs to add headers like content-type, etc... if it's processing on a different path, it could just be accidentally avoiding (but not actually un-susceptible to) the error in question. |
BTW, another reason I can't just only set headers in the My only viable option here is to be able to call |
UPDATE: This post seems to have identified the culprit, or at least pointed at where the probable problem lies. The problem seems to be that a HEAD request comes into my code as shown above, and the HSTS header is set, and then I'm not fully versed on this, but here are a few assumptions/observations that I'd think of initially:
|
Further analysis from that thread:
From my reading, that sounds like both a bug in node-static and also in Node itself. Thoughts? |
@getify Nope, calling |
After adding a
Here's the input data:
|
@1ns3cur3 that's strange, i'm definitely not seeing that. |
So far, HEAD shouldn't send headers which GET wouldn't; which I guess you aren't. Other than that, yes, you can call |
I'm using Node 10.1.0, and node-static v0.7.2. The error stack in my logs:
I'm experiencing this persistent error every single time a specific kind of request comes in -- but only for that, all other requests are fine -- which appears to be a request from a Slackbot. Here are the request headers from the specific request:
Here's my code:
As you can see, my server is running on
localhost:8003
-- I have a public server on 80/443 that proxies the requests after doing SSL certificate handling, etc.In my debugging, I have narrowed down that the error happens inside of the
staticServer.serve(..)
call itself, not in this code shown.And the
res.setHeader(..)
call that I make beforeserve(..)
seems to cause the error, though I don't understand why. If I comment that line of code out, the error stops.But my understanding is that me calling
setHeader(..)
only queues up a header to be sent. It's not supposed to flush headers or anything, only prepare a header for later sending. I don't have any other calls in that code path tores.writeHead(..)
or anything, so I can't figure out how the error is getting triggered.I am aware that I could set this response header in the
new nodeStatic.Server(..)
constructor call. But I don't want to do it there, because I actually need to be able to set specific headers on a per-request basis under certain conditions, and that approach sets headers for all static-file responses.Can you help me figure out why, in only this one specific Slackbot request case, my call to
setHeader(..)
is triggering logic in node-static that causes this error? I'm really perplexed.The text was updated successfully, but these errors were encountered: