Skip to content

Commit eda740e

Browse files
docs: udpate documentation for proxies and static directory hosting
1 parent 6660ccd commit eda740e

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

packages/iframe-coordinator/README.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,36 +139,35 @@ Options:
139139
Keep in mind that the config file is not a true commonJS module, and
140140
will be evaluated directly inside the browser in an immediately invoked
141141
function expression.
142+
```
142143

143-
The CLI host app also provides a proxy route under `/proxy/` that can be used
144-
if you need the client and host applications on the same domain. To use the proxy,
145-
simply make the url registered for the client that of the host app, followed by
146-
`/proxy/` and then the url of the client app. (See `app2` in the config below
147-
for an example)
144+
The CLI host app also provides a proxy config file that can be used
145+
if you need the client and host applications on the same domain. (See `app2` in the config below
146+
for an example).
148147

149-
Here is an example config file:
148+
`ifc-cli-config.js`
150149

150+
```json
151151
module.exports = function(frameRouter) {
152152
frameRouter.clientConfig = {
153153
clients: {
154154
app1: {
155-
url: 'http://localhost:8080/client-app-1/#/',
155+
url: '/client-app-1/#/',
156156
assignedRoute: '/app1'
157157
},
158158
app2: {
159-
// Instead of directly referencing client 2 via "url: `http://${hostname}:8080/client-app-2/#/`"
160-
// we use the built-in proxy route so it can share the same domain as the host app.
161-
url: `${window.location.origin}/proxy/${encodeURI(
162-
`http://${hostname}:8080/client-app-2/#/`
163-
)}`,
159+
url: '/client-app-2/#/',
164160
assignedRoute: '/app2',
165161
sandbox: 'allow-presentation', // optional
166162
allow: 'microphone http://localhost:8080;' // optional
167163
}
168164
},
169165
envData: {
170166
locale: 'en-US',
171-
hostRootUrl: window.location.origin,
167+
hostRootUrl:
168+
window.location.origin +
169+
window.location.pathname +
170+
window.location.search,
172171
custom: getCustomClientData()
173172
}
174173
};
@@ -185,6 +184,25 @@ function getCustomClientData() {
185184
}
186185
```
187186

187+
`ifc-proxy.config.json`
188+
189+
```json
190+
{
191+
"static": {
192+
// Instead of directly referencing client 2 via "url: `http://${hostname}:8080/client-app-2/#/`"
193+
// we create a static directory for the second client.
194+
"/client-app-2": "http://${hostname}:8080"
195+
},
196+
// This file also has support for basic proxy configurations
197+
"proxies": {
198+
"something": {
199+
path: "/something"
200+
target: "http://www.example.org/something"
201+
}
202+
}
203+
}
204+
```
205+
188206
### Development
189207

190208
#### Installation

0 commit comments

Comments
 (0)