@getpaseo/relay 0.1.105 → 0.1.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
+
import { createCutoverProxy } from "./cutover-proxy.js";
|
|
19
20
|
const LEGACY_RELAY_VERSION = "1";
|
|
20
21
|
const CURRENT_RELAY_VERSION = "2";
|
|
21
22
|
function resolveRelayVersion(rawValue) {
|
|
@@ -469,6 +470,9 @@ export class RelayDurableObject {
|
|
|
469
470
|
*/
|
|
470
471
|
export default {
|
|
471
472
|
async fetch(request, env) {
|
|
473
|
+
if (env.PASEO_RELAY_UPSTREAM) {
|
|
474
|
+
return createCutoverProxy(env.PASEO_RELAY_UPSTREAM).fetch(request);
|
|
475
|
+
}
|
|
472
476
|
const url = new URL(request.url);
|
|
473
477
|
// Health check
|
|
474
478
|
if (url.pathname === "/health") {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function createCutoverProxy(origin) {
|
|
2
|
+
const originUrl = new URL(origin);
|
|
3
|
+
return {
|
|
4
|
+
async fetch(request) {
|
|
5
|
+
const upstreamUrl = new URL(request.url);
|
|
6
|
+
upstreamUrl.protocol = originUrl.protocol;
|
|
7
|
+
upstreamUrl.host = originUrl.host;
|
|
8
|
+
return fetch(new Request(upstreamUrl, request));
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=cutover-proxy.js.map
|