node-source-map-support
node-source-map-support copied to clipboard
Refused to get unsafe header "SourceMap"
I'm trying to use this module in the browser in combination with bluebird and webpack.
I'm loading it via import 'source-map-support/register' and all builds fine but when I run the code in the browser I throws
Refused to get unsafe header "SourceMap"
Refused to get unsafe header "X-SourceMap"
any ideas what is going wrong here?
- Chrome Version 43.0.2357.81 (64-bit) (Mac)
- [email protected] node_modules/source-map-support

@Dignifiedquire: Not sure if you're using webpack-dev-server too, but we saw the same thing and have set the following headers option:
new WebpackDevServer(compiler, {
...
headers: { 'Access-Control-Expose-Headers': 'SourceMap,X-SourceMap' }
...
});
See:
While exposing the appropriate headers is definitely a must when source maps are being sent over the network, I might argue that trying to access these headers is entirely unnecessary when the source maps are inlined. I would suggest that this library first check if sourcemaps are already present and only if not try to access these headers to check if there are sourcemaps available through the network.
Is there any known solution to this issue?
FYI the workaround that worked for me was to use inline source maps and remove this code block:
if (isInBrowser()) {
var xhr = new XMLHttpRequest();
xhr.open('GET', source, false);
xhr.send(null);
fileData = xhr.readyState === 4 ? xhr.responseText : null;
// Support providing a sourceMappingURL via the SourceMap header
var sourceMapHeader = xhr.getResponseHeader("SourceMap") ||
xhr.getResponseHeader("X-SourceMap");
if (sourceMapHeader) {
return sourceMapHeader;
}
}
Any updates on this? I'm sill seeing the same issue from that same code block.
I'm getting this also