You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: nodejs/README.md
+97-20Lines changed: 97 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,21 +13,21 @@ Any subdomain of `*.backloop.dev` points to `localhost`!
13
13
**Exception:**`backloop.dev`, which points to a page where you can download the certificates.
14
14
15
15
16
-
## Why?
16
+
## Why?
17
17
18
-
**backloop.dev** solves [mixed-content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) issues when developing a WebApp or Backend on local environement while accessing ressources on remote HTTPS sources.
18
+
**backloop.dev** solves [mixed-content](https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content) issues when developing a WebApp or Backend on local environment while accessing resources on remote HTTPS sources.
19
19
20
-
The issue is often raised by the [same-origin policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) mechanism that restricts the loading of resources from another origin unless this can be allowed by sending correct [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) headers.
20
+
The issue is often raised by the [same-origin policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) mechanism that restricts the loading of resources from another origin unless this can be allowed by sending correct [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) headers.
21
21
22
-
Which anyway will fall-back on the must-have "non-mixed-content" (No HTTP & HTTPS)
22
+
Which anyway will fallback on the must-have "non-mixed-content" (no HTTP & HTTPS).
23
23
24
24
But making requests to **HTTPS APIs** from **HTTP** sites on **localhost** would not be possible without changing security options on your browser, which is why **backloop.dev** provides SSL certificates with a full loopback domain, to let anyone benefit from a signed certificate on **localhost**.
25
25
26
26
## Where are the certificates?
27
27
28
-
Certificates are not bundled with the npm package, but downloaded and updated from [backloop.dev](https://backloop.dev) at installation and runtime, or manually with `backloop.dev-update`. To specify in which directory the certificates should be stored set the environement var`BACKLOOP_DEV_CERTS_DIR`.
28
+
Certificates are not bundled with the npm package, but downloaded and updated from [backloop.dev](https://backloop.dev) at installation and runtime, or manually with `backloop.dev-update`. To specify in which directory the certificates should be stored, set the environment variable`BACKLOOP_DEV_CERTS_DIR`.
29
29
30
-
If the certificates are outdated they are checked and updated at boot.
30
+
If the certificates are outdated, they are checked and updated at boot.
31
31
32
32
## Usage
33
33
@@ -42,19 +42,88 @@ Add `-g` to use `backloop.dev` and `backloop.dev-proxy` globally.
42
42
43
43
(Don't forget to prefix commands with `npx` if not installed globally.)
44
44
45
-
Start a webserver serving the contents of a directory on `https://whatever.backloop.dev:<port>/`:
45
+
#### Static file server
46
+
47
+
Serve the contents of a directory on `https://whatever.backloop.dev:<port>/`:
46
48
47
49
```
48
50
backloop.dev <path> [<port>]
49
51
```
50
52
51
-
Start a proxy on `https://whatever.backloop.dev:<port>/`
52
-
Note: proxy will add `x-forwarded-proto: https` to headers. This is to support express-session and other services and advertise it was served in https.
53
+
Example:
54
+
```bash
55
+
backloop.dev ./dist 4443
56
+
# Server started on port 4443 serving files in './dist'
57
+
# Open https://myapp.backloop.dev:4443/
58
+
```
59
+
60
+
#### Reverse proxy
61
+
62
+
Proxy requests from `https://whatever.backloop.dev:<port>/` to a backend.
63
+
Supports `http://` and `https://` targets, with optional base path.
64
+
Note: adds `x-forwarded-proto: https` to headers for express-session and similar services.
-`https://app.backloop.dev:7654/` serves static files from `./dist`
106
+
-`https://api.backloop.dev:7654/` proxies to `http://localhost:3000/v1`
107
+
-`https://admin.backloop.dev:7654/` proxies to `https://anotherwebsite.com:8443`
108
+
109
+
Paths are resolved relative to the config file location.
110
+
111
+
**Path-based routing** is also supported. Use `hostname/path/` keys (trailing slash required) to route different URL prefixes to different handlers on the same hostname:
112
+
113
+
```json
114
+
{
115
+
"port": 7654,
116
+
"hostnames": {
117
+
"tom/static/": { "path": "./public" },
118
+
"tom/": { "proxy": "http://localhost:3000" }
119
+
}
120
+
}
121
+
```
122
+
123
+
Here `https://tom.backloop.dev:7654/static/app.js` serves `./public/app.js`, while `https://tom.backloop.dev:7654/api/users` proxies to `http://localhost:3000/api/users`. The longest matching prefix wins.
124
+
125
+
#### Certificate update
126
+
58
127
Manually force update of the certificates:
59
128
60
129
```
@@ -63,7 +132,7 @@ backloop.dev-update
63
132
64
133
### Certificate files
65
134
66
-
You can download the certificates files on [backloop.dev](https://backloop.dev) for your own usage.
135
+
You can download the certificate files on [backloop.dev](https://backloop.dev) for your own usage.
0 commit comments