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

ports #1

Closed
ralyodio opened this issue Oct 5, 2012 · 5 comments
Closed

ports #1

ralyodio opened this issue Oct 5, 2012 · 5 comments

Comments

@ralyodio
Copy link

ralyodio commented Oct 5, 2012

Do i need to add the port?

My app runs on port 8080 in development and port 80 in production.

I have a config variable I can use, but it includes http://example.com:8080 or http://example.com

Can I just use that

app.use(require('node-force-domain').redirect(cfg.site_url));

@goloroden
Copy link
Member

Unfortunately, ports are not supported at the moment :-(
It does also not help if you provide the complete url, as only the host part is used within the middleware.

Basically, I need to extend the code to support ports as well (will do that, but it will take me a few days until I find the time).

Interface should (will) be

app.use(require('node-force-domain').redirect('www.example.com', 8080));

with the port as an optional parameter.

Would that be fine for you?

@ralyodio
Copy link
Author

ralyodio commented Oct 5, 2012

I think you shold make it use the http too...this is what I did.

app.all(/./, function(req, res, next) {
var host = req.header("host");
if (!host.match(/^www..
/i)) {
next();
} else {
res.redirect(301, cfg.site_url+req.path);
}
})

Where cfg.site_url can be http://example.com:3000

@ralyodio
Copy link
Author

ralyodio commented Oct 5, 2012

I created a new package: npm install express-force-domain

@goloroden
Copy link
Member

Why didn't you just update the existing one and send a pull request?

@ralyodio
Copy link
Author

ralyodio commented Oct 6, 2012

i was going to but after reading through your code it seems to be doing a bit more than what I was needing.

@ralyodio ralyodio closed this as completed Oct 6, 2012
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

No branches or pull requests

2 participants