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
weird redirect issue when using apache proxy #9
Comments
Yes, it should be opt-in, I agree. I'll make sure to swap the default value on the next major version bump.
When the redirect occurs, what does Node.js see as the |
node sees req.url as |
as far as redirecting, i use config.baseURL to redirect properly when nested under apache. so potentially you could redirect relatively.. since yea, you couldn't know my config values. |
Yea, how about |
What you could do is use a module like |
hmmmm.. now that i went through my whole app adding the prefix.. i'll look into it. is that a proper standard or is it still a good idea for you to redirect relatively? |
sorry, I don't understand the question :) technically the |
hmm so I'm kind of curious about the redirect code anyway, does it just add slash? And just for the purpose of cleaning up the url? because if so I think you could get away with removing it unless it has a bigger use. If you really need the redirect part, could I suggest opt-in by letting the user input either |
Simple example (added very high in your middleware stack): var onHeaders = require('on-headers')
app.use(function (req, res, next) {
onHeaders(res, function () {
var location = this.getHeader('Location')
if (location) {
this.setHeader('Location', config.baseURL + location)
}
})
next()
})
Yea, I don't think should do that by default.
https://github.com/expressjs/serve-static/blob/master/index.js#L91 it adds a
Yea, I can probably change the |
It doesn't seem to include This is what I was wondering when I originally saw the piece of code since I didn't think there was much directory support. is the |
If you put a |
For example, put a file |
In case it helps, you were talking about Apache, so giving you some examples may help. The |
I see what you mean now. Serving index.html when they hit the parent directory just like an apache www will do. I was thinking hitting the parent directory would give you a list of the files in that directory, as if you were on a read only ftp client. I guess I didn't really expect people to use node to serve straight html like that but I guess they could. I still don't see the need to redirect, even if you're serving indexes like this though, right? |
Say your <img src="ball.gif"> to show a bouncing ball. The Now, if you don't redirect, when a user goes to |
ah.. hmm. It's unlikely that anyone will find the solution would be |
hm, I'm not sure what the question really means, but this is a common problem with using |
well it might be better to leave it in as default then, since nesting under an apache route is probably more rare. |
So yea. As long as this module is doing |
So, I had no idea why my app was breaking, but apparently it was being redirected for no apparent reason.
apache redirects
/mypath
to my node appwhen it wasn't behind apache it was fine, but then suddenly it was being picked up by the serve-static middleware. and only sometimes. i'm using serve static for
/vendor
and/public
. Several sub applications nested under the main node app each have apublic
and avendor
dir. Only the sub apps that have avendor
are having this issue ( very weird since the hooks are identical ).normally(not behind apache) going to
/subapp
will load the sub app just fine, doesn't pick up the directory serve-static.when nested under apache, going to
/mypath/subapp
, your application will redirect my app to/subapp/
, which is not picked up by apache. This is totally unexpected, and it should be going to/mypath/subapp/
. I would think this middleware would just give me files not mess with my redirects at all. So I had to set redirect: false.I think this should be opt-in, since this middleware is supposed to be boilerplate basic serving files and not redirecting. That or make the detect for redirect better since it is being overzealous and breaking my url.
The text was updated successfully, but these errors were encountered: