-
Notifications
You must be signed in to change notification settings - Fork 755
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
Charset problem #661
Comments
Same problem here, we are also stuck with ISO-8859-1. |
None of matter with you but http://prnt.sc/ is too slow... Just pasting the image to the Github issue comment is easier and more useful. https://help.github.com/articles/issue-attachments/ |
I'm trying to nail this down, so far the problem is confirmed to be upstream, related to the foxy proxy, and there is even an open issue regarding encoding problems: |
Here's a small gist for testing: |
Any solution? I am using iso-8859-1 unfortunately I can not change the application Chasert it causes problems in other services. |
please fix this one |
I'm having this problem too. Any fix available? |
@shakyShane Please fix! |
me too 👅 |
Any news or workaround on this problem? |
Based on @kokarn's and @youngzhaosignifyd's examples and with the help of iconv-lite, plus using proxyRes option I am successfully using this script: proxyRes: [
(proxyRes, req, res) => {
if( proxyRes.headers && proxyRes.headers["content-type"] &&
proxyRes.headers["content-type"].match("text/html") ) {
const _end = res.end
const _writeHead = res.writeHead
let writeHeadArgs
let buffer = new Buffer("")
proxyRes.on("data", (chunk) => {
buffer = Buffer.concat([buffer, chunk])
})
res.write = () => {};
res.writeHead = (...args) => {writeHeadArgs = args}
res.end = () => {
_writeHead.apply(res, writeHeadArgs)
_end.call(res, iconv.decode(buffer, "iso-8859-2"))
}
}
}
] |
My solution, strongly based on @skotniczny solution. I had to set a var browserSync = require("browser-sync").create();
var iconv = require("iconv-lite");
/**
* This example will serve files from the './app' directory
* and will automatically watch for html/css/js changes
*/
browserSync.init({
watch: false,
proxy: {
target: "http://localhost/WorkServer/admin",
proxyRes: [
(proxyRes, req, res) => {
if (
proxyRes.headers &&
proxyRes.headers["content-type"] &&
proxyRes.headers["content-type"].match("text/html")
) {
const _end = res.end;
const _writeHead = res.writeHead;
let writeHeadArgs;
let buffer = new Buffer("");
proxyRes.on("data", chunk => {
buffer = Buffer.concat([buffer, chunk]);
});
res.write = () => {};
res.writeHead = (...args) => {
writeHeadArgs = args;
};
res.end = () => {
_writeHead.apply(res, writeHeadArgs);
_end.call(res, iconv.decode(buffer, "win1252"));
};
}
},
function(res) {
if (
res.headers &&
res.headers["content-type"] &&
res.headers["content-type"].match("text/html")
)
res.headers["content-type"] = "text/html; charset=utf-8";
}
]
}
}); |
I'm trying to use the code above but I'm getting the following error: node:_http_server:279
throw new ERR_HTTP_INVALID_STATUS_CODE(originalStatusCode);
^
RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined Any idea what could be missing in my case? |
Fixed version. Tested node v17.9.0. var browserSync = require("browser-sync").create();
var iconv = require("iconv-lite");
browserSync.init({
watch: false,
proxy: {
target: "http://mydomain.local",
proxyRes: [
(proxyRes, req, res) => {
if (
proxyRes.headers &&
proxyRes.headers["content-type"] &&
proxyRes.headers["content-type"].match("text/html")
) {
const _end = res.end;
const _writeHead = res.writeHead;
let buffer = Buffer.from("");
proxyRes.on("data", chunk => {
buffer = Buffer.concat([buffer, chunk]);
});
res.write = () => {};
res.writeHead = (...args) => {
_writeHead.apply(res, args);
};
res.end = () => {
_end.call(res, iconv.decode(buffer, "iso-8859-1"));
};
}
},
function(res) {
if (
res.headers &&
res.headers["content-type"] &&
res.headers["content-type"].match("text/html")
)
res.headers["content-type"] = "text/html; charset=utf-8";
}
]
}
}); |
I'm having problems with charset, naturally the codes in .aspx need (and I don't know ecxacly why) the ISO-8859-1. Prints someting like this: *capacita��o de *
With aspx, ours programmers insert the content of news, in web.config I found this.
http://prntscr.com/7eitat
But if i change the value of charset here, nothing more works.
The text was updated successfully, but these errors were encountered: