I've got an Express server running with the following cors
middleware config:
app.use(
cors({
origin: [
/^http:\/\/localhost:\d+/,
/^https:\/\/щоденниквражень\.укр/,
/^https:\/\/xn--80adfecflqzagb7a3ioc\.xn--j1amh/,
],
}),
);
(xn--80adfecflqzagb7a3ioc.xn--j1amh
is the Punycode representation of щоденниквражень.укр
)
I have made requests to https://api.щоденниквражень.укр from a page hosted at https://щоденниквражень.укр. Most browsers send the Punycode representation in the Origin
header, which works as expected.
But IE11 sends the raw https://щоденниквражень.укр
. It is supposed to match the second regex in the list, but on the server side I get the following header value from req.headers.origin
:
Origin: https://Ñ Ð¾Ð´ÐµÐ½Ð½Ð¸ÐºÐ²ÑаженÑ.ÑкÑ
which, obviously, fails to match any of the regexes (some characters may have been displayed incorrectly but you got the idea - the charset is wrong).
Is it possible to fix this issue? I guess I should probably set the encoding - but I don't know where to do it and which one to choose. Any help is appreciated!