Skip to content

Commit

Permalink
Change default tld to .test (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeansaad authored Nov 5, 2021
1 parent da0858f commit 027ea0e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ If you're upgrading, please be sure to:

## Features

- **Local domains** - `http://project.localhost`
- **HTTPS via local self-signed SSL certificate** - `https://project.localhost`
- **Wildcard subdomains** - `http://*.project.localhost`
- **Local domains** - `http://project.test`
- **HTTPS via local self-signed SSL certificate** - `https://project.test`
- **Wildcard subdomains** - `http://*.project.test`
- **Works everywhere** - macOS, Linux and Windows
- **Works with any server** - Node, Ruby, PHP, ...
- **Proxy** - Map local domains to remote servers
Expand All @@ -60,7 +60,7 @@ You can also visit https://nodejs.org.

### Local domains (optional)

To use local `.localhost` domains, you need to configure your network or browser to use chalet's proxy auto-config file or you can skip this step for the moment and go directly to http://localhost:2000
To use local `.test` domains, you need to configure your network or browser to use chalet's proxy auto-config file or you can skip this step for the moment and go directly to http://localhost:2000

[**See instructions here**](https://github.com/jeansaad/chalet/blob/master/docs/README.md).

Expand All @@ -73,7 +73,7 @@ To use local `.localhost` domains, you need to configure your network or browser
~/projects/two$ chalet run 'npm start'
```

Visit [localhost:2000](http://localhost:2000) or [http(s)://chalet.localhost](http://chalet.localhost).
Visit [localhost:2000](http://localhost:2000) or [http(s)://chalet.test](http://chalet.test).

Alternatively you can directly go to

Expand All @@ -83,8 +83,8 @@ http://localhost:2000/two
```

```
http(s)://one.localhost
http(s)://two.localhost
http(s)://one.test
http(s)://two.test
```

#### Popular servers examples
Expand Down Expand Up @@ -118,8 +118,8 @@ Add your remote servers
You can now access them using

```sh
http://aliased-address.localhost # will proxy requests to http://192.168.1.12:1337
http://aliased-domain.localhost # will proxy requests to http://google.com
http://aliased-address.test # will proxy requests to http://192.168.1.12:1337
http://aliased-domain.test # will proxy requests to http://google.com
```

## CLI usage and options
Expand Down Expand Up @@ -170,7 +170,7 @@ chalet add "cmd -p %PORT%" # Windows

## Fallback URL

If you're offline or can't configure your browser to use `.localhost` domains, you can **always** access your local servers by going to [localhost:2000](http://localhost:2000).
If you're offline or can't configure your browser to use `.test` domains, you can **always** access your local servers by going to [localhost:2000](http://localhost:2000).

## Configurations, logs and self-signed SSL certificate

Expand All @@ -195,8 +195,8 @@ By default, `chalet` uses the following configuration values:
// Timeout when proxying requests to local domains
"timeout": 5000,

// Change this if you want to use another tld than .localhost
"tld": 'localhost',
// Change this if you want to use another tld than .test
"tld": 'test',

// If you're behind a corporate proxy, replace this with your network proxy IP (example: "1.2.3.4:5000")
"proxy": false
Expand Down Expand Up @@ -251,7 +251,7 @@ chalet add --http-proxy-env 'server-cmd'
chalet add --change-origin 'https://jsonplaceholder.typicode.com'
```

_When proxying to a `https` server, you may get an error because your `.localhost` domain doesn't match the host defined in the server certificate. With this flag, `host` header is changed to match the target URL._
_When proxying to a `https` server, you may get an error because your `.test` domain doesn't match the host defined in the server certificate. With this flag, `host` header is changed to match the target URL._

#### `ENOSPC` and `EACCES` errors

Expand Down
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Configuring local .localhost domains
# Configuring local .test domains

_This step is totally optional and you can use chalet without it._

To use local `.localhost` domain, you need to configure your browser or network to use chalet's proxy auto-config file which is available at `http://localhost:2000/proxy.pac` [[view file content](../src/daemon/views/proxy-pac.pug)].
To use local `.test` domain, you need to configure your browser or network to use chalet's proxy auto-config file which is available at `http://localhost:2000/proxy.pac` [[view file content](../src/daemon/views/proxy-pac.pug)].

**Important** chalet MUST be running before configuring your network or browser so that `http://localhost:2000/proxy.pac` is available. If chalet is started after and you can't access `.localhost` domains, simply disable/enable network or restart browser.
**Important** chalet MUST be running before configuring your network or browser so that `http://localhost:2000/proxy.pac` is available. If chalet is started after and you can't access `.test` domains, simply disable/enable network or restart browser.

## Configuring another .tld

You can edit `~/.chalet/conf.json` to use another Top-level Domain than `.localhost`.
You can edit `~/.chalet/conf.json` to use another Top-level Domain than `.test`.

```json
{
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = group => {
// localhost router
app.use(indexRouter);

// Handle CONNECT, used by WebSockets and https when accessing .localhost domains
// Handle CONNECT, used by WebSockets and https when accessing .test domains
server.on("connect", (req, socket, head) => {
group.handleConnect(req, socket, head);
});
Expand Down
4 changes: 2 additions & 2 deletions src/daemon/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class Group extends EventEmitter {
const { item } = req.chalet;

// Handle case where port is set
// http://app.localhost:5000 should proxy to http://localhost:5000
// http://app.test:5000 should proxy to http://localhost:5000
if (port) {
const target = `http://127.0.0.1:${port}`;

Expand Down Expand Up @@ -385,7 +385,7 @@ class Group extends EventEmitter {
}
}

// Handle CONNECT, used by WebSockets and https when accessing .localhost domains
// Handle CONNECT, used by WebSockets and https when accessing .test domains
handleConnect(req, socket, head) {
if (req.headers.host) {
const { host } = req.headers;
Expand Down
2 changes: 1 addition & 1 deletion test/daemon/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ test.cb("GET http://failing.tld should return 502", t => {
});

test.cb(
"GET http://proxy.tld should return 200 and host should be proxy.localhost",
"GET http://proxy.tld should return 200 and host should be proxy.test",
t => {
request(app)
.get("/")
Expand Down

0 comments on commit 027ea0e

Please sign in to comment.