# connect-base

> Get the base url for Express/Connect

Latest version **0.1.7** (published 2014-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install connect-base
pnpm add connect-base
yarn add connect-base
bun add connect-base
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2014-01-28 |
| First published | 2013-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Cameron Bytheway |
| Maintainers | camshaft |

## Links

- npm: https://www.npmjs.com/package/connect-base
- Repository: https://github.com/camshaft/connect-base
- Issues: https://github.com/camshaft/connect-base/issues
- npm.io page: https://npm.io/package/connect-base

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ~0.7.2

## Recent versions

- 0.1.7 (latest) — 2014-01-28
- 0.1.6 — 2013-08-31
- 0.1.5 — 2013-04-09
- 0.1.4 — 2013-04-09
- 0.1.3 — 2013-04-05
- 0.1.2 — 2013-04-05
- 0.1.1 — 2013-03-24
- 0.1.0 — 2013-03-22
- 0.0.2 — 2013-02-14
- 0.0.1 — 2013-01-15
- 0.0.0 — 2013-01-15

## README

connect-base [![Build Status](https://travis-ci.org/CamShaft/connect-base.png?branch=master)](https://travis-ci.org/CamShaft/connect-base)
============

Get the base url for Express/Connect apps

Use
---

Set up a server that echoes the requesting url:

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

app.use(base());

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

When we request it locally:

```sh
curl http://localhost:5000
> http://localhost:5000
```

When we host it through a DNS server:

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

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

```sh
curl -H "X-Forwarded-Proto: https" http://example.com
> https://example.com
```

```sh
curl -H "X-Forwarded-Host: test.example.com" http://example.com
> http://test.example.com
```

```sh
curl -H "X-Forwarded-Port: 8080" http://example.com
> http://example.com:8080
```

```sh
curl -H "X-Forwarded-Path: /testing" http://example.com
> http://example.com/testing
```

Testing
-------

```sh
npm install -d
npm test
```

---
_Source: https://npm.io/package/connect-base · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
