-
Notifications
You must be signed in to change notification settings - Fork 581
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
Static rewrite issue #283
Comments
URL rewriting configuration is a little bit like PERL programming: write only language. Did you check out the URL rewrite rules in the web.config template in http://tomasz.janczuk.org/2012/05/yaml-configuration-support-in-iisnode.html? They should cover your needs I think. |
Thank you for reply. Yes, I actually did use the exact config from that post, with no luck :( |
I believe the issue is because {REQUEST_URI} includes the subdirectory that the node application is in ("foo" in this case). So the rewrite is turning "/css/style.css" into "public/foo/css/style.css", which is not what is expected. The only workaround I know of besides not hosting your node app in a subdirectory is nesting your static files on level deeper in a folder named the same as your application. For example:
This allows you to use the boilerplate static rewrite rule: <rule name="StaticContent">
<action type="Rewrite" url="public{{REQUEST_URI}}"/>
</rule> |
+1... |
Is it open because actually there's no solution for it to server static files? Or is it open just because the author didn't find a solution for his problem. |
@tjanczuk @rramachand21 I am running iisnode and node.js. app.use(express.static(__dirname + "public"));
app.use(express.static("public")); this is my route: app.get("/usina2", function(req, res) {
res.render("index.ejs");
}); |
I'm having the same problem as @aeciolevy , the only difference is that I handle the url rewriting in app.js that gets pulled into start.js. I tried nesting the public folder contents in a folder named the same as the app, but that didn't work. It's got to be a simple thing that I'm missing... |
Bump. Running into this same exact issue. |
Has this worked? I am having problems serving CSS and JS files. I have defined the following in The 'css_js_files' directory is in the same directory as my server.js. But, I I always get '404' error for the CSS or JS files that I try to load from the EJS file using I am using the following rule in my web.config.
Last but not the least, I have 'myapp' virtual directory created in IIS. So, my URL looks like 'http://localhost/myapp/index.html' |
Banged my head against the wall with this issue. I only wanted to serve static files in my root/styles- and root/scripts-folder. This finally solved it for me, and is independent of location of files:
|
Unless it's important that Express handle your static files, why not let IIS handle it for you? Add a condition of conditions to exclude your static files from the rewrite rule and they will fall back to IIS serving your static content. Something like:
|
|
Pretty sure this is due to my ineptitude, so I apologize in advance, but here goes:
IIS8 with rewrite module.
node Express app, hosted on default web site, under directory "/foo".
So the dir structure is "foo/app.js", "foo/public/css/styles.css" etc.
Accessed like "http://localhost/foo" or "http://pc-name/foo" over LAN.
Rewrite rules in web.config is setup as recommended:
Routes in app.js are set up like so:
Express static handling turned off.
This resulted in 404 for any of the static files.
My solution, which worked, is to make a rule for each static file in web.config individually like so:
and set links in the template like so:
Which makes them load properly, but it seems hackish and is kind of a PITA to do it this way.
The question is, how to do it properly?
The text was updated successfully, but these errors were encountered: