Skip to content
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

less.js: Error on the Accept header when including a less file with a plugin #3336

Closed
g3rv4 opened this issue Nov 30, 2018 · 0 comments · Fixed by #3337
Closed

less.js: Error on the Accept header when including a less file with a plugin #3336

g3rv4 opened this issue Nov 30, 2018 · 0 comments · Fixed by #3337

Comments

@g3rv4
Copy link
Contributor

g3rv4 commented Nov 30, 2018

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;
        });
    }
})

This, when hosted on IIS, returns this error:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant