0
votes

I want to do client-side compiling of my less styles for development. But Express does not serve a static file like this:

In Express app.use(express.static(__dirname + '/public'));

The webpage loads fine, except this file returns nothing

<link rel="stylesheet/less" type="text/css" href="styles.less">

The response is:

HTTP/1.1 200 OK
X-Powered-By: Express
Date: Sat, 21 Jan 2012 10:25:18 GMT
Cache-Control: public, max-age=0
Last-Modified: Sat, 21 Jan 2012 10:24:52 GMT
ETag: "396-1327141492000"
Content-Type: application/octet-stream
Accept-Ranges: bytes
Content-Length: 396
Connection: keep-alive

This also returns nothing

<link rel="stylesheet" type="text/css" href="styles.less">

And this also returns nothing

<link rel="stylesheet/less" type="text/css" href="styles.css">

But this works

<link rel="stylesheet" type="text/css" href="styles.css">

How can I do client-side less with express? It works on Apache.

Thanks,

1
This should work OK, provided you are including "less.js" in your client page, before the <link> tags. Could you update your question, and post your node.js application code?Philippe Plantier
Well, you are correct. It does work. But the problem must have to do with some kind of cross domain thing. The express server that is serving this command is not the same as the web page's.user1153660
It looks like my problem is a same-origin problem. You were right, it does work. But my web page loads from one domain, and then all the CSS and Javascript come from another domain (the express server). This is allowed for CSS and JavaScript, but the less files are not either of them and must run afoul of the same-origin rule. Any ideas?user1153660
Well, this may not be what you want, but you may 1) Serve static resources from the first domain, or 2) Keep them on a the Express server, but use some kind of reverse proxy to dispatch request to the Express server and achieve the same effect. If you are separating domains to avoid cookie overhead, 1 and 2 will be useless, though. There is always 3) use Express to do server-side parsing of less stylesheets, and serve them as CSS.Philippe Plantier

1 Answers

0
votes

I'm fairly certain the issue is with mime type. I don't know how to fix it with express though.