less.js: Error on the Accept header when including a less file with a plugin
g3rv4 opened this issue · 1 comments
g3rv4 commented
Description
When using less.js and including a file using a <link>
element with a plugin, the Accept
header that's sent when GETting the plugin is text/css
. This causes IIS to return 406 Not Acceptable
.
Steps to repro:
You can visit https://lessbug.azurewebsites.net/ where I put together a project showing the issue. The code of this project is on GitHub.
There are 3 files involved.
index.html
:
<html>
<head>
<link rel="stylesheet/less" type="text/css" href="test.less">
<script>
less = {
env: "development"
};
</script>
<script src="https://unpkg.com/less@3.9.0/dist/less.js"></script>
</head>
</html>
test.less
:
@plugin 'less-plugin.js';
.something {
color: red;
pi: pi()
}
less-plugin.js
:
registerPlugin({
install: function (less, pluginManager, functions) {
functions.add('pi', function () {
return Math.PI;
});
}
})
When inspecting the network logs, you can see that the request headers contain Accept: text/css
IIS, as it knows the content type for a javascript file is application/javascript
, returns a 406 Not Acceptable
HTTP error.
I'm creating a PR with my proposed solution.
g3rv4 commented
ouch, wrong repo