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
Content-Type:application/octet-stream
being set for subsequent middleware
#23
Comments
thanks for taking the time to triage this. I'll be sure to tag you in the PR if I get to it before you. |
I opened a PR with a minimal fix, but obviously things remain quite brittle. While I was trying to think of a way to solve this I came up with a few other ideas:
|
Already mentioned in #15 (and leecade/koa-webpack-middleware#23), but I thought I'd open a new issue.
Content-Type:application/octet-stream
is being set for any middleware hit after this one. Besides being generally incorrect if you're trying to respond with html/text/json, it causes the browser (Chrome at least) to prompt for a download. Working around it means manually settingctx.type
to something more appropriate, or else making sure the webpack middleware only gets called on a route where it won't be a problem.This behaviour is a symptom of
context.body
being unconditionally set to a stream (the passthrough) in the hot middleware part here. As soon ascontext.body
gets assigned, Koa sets the appropriate content type, which then remains even after later reassigningbody
to a string or whatever.Side note:
writeHead
should be settingcontext.status
, notcontext.state
, it should look like this:But the method that has been used to hook-in seems a bit hacky and brittle in general to me. I'll see if I can find the time to put together a PR, just wanted to raise this issue while it's in my head.
Thanks for creating this repo by the way, the other one isn't maintained very well 😛
The text was updated successfully, but these errors were encountered: