0.1.7 • Published 10 years ago

connect-base v0.1.7

Weekly downloads
1,588
License
-
Repository
github
Last release
10 years ago

connect-base Build Status

Get the base url for Express/Connect apps

Use

Set up a server that echoes the requesting url:

var app = connect();
    base = require("connect-base");

app.use(base());

app.use(function(req, res){
  res.send(req.base);
})

When we request it locally:

curl http://localhost:5000
> http://localhost:5000

When we host it through a DNS server:

curl http://example.com
> http://example.com

We can also set the protocol, host, port, and path; maybe through a reverse proxy

curl -H "X-Forwarded-Proto: https" http://example.com
> https://example.com
curl -H "X-Forwarded-Host: test.example.com" http://example.com
> http://test.example.com
curl -H "X-Forwarded-Port: 8080" http://example.com
> http://example.com:8080
curl -H "X-Forwarded-Path: /testing" http://example.com
> http://example.com/testing

Testing

npm install -d
npm test
0.1.7

10 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago