()
| 75 | ) {} |
| 76 | |
| 77 | async createTunnel(): Promise<string> { |
| 78 | const response = await fetch(`https://admin.${this.host}/api/tunnels`, { |
| 79 | method: "POST", |
| 80 | headers: { |
| 81 | accept: "application/json", |
| 82 | authorization: `Bearer ${this.apiKey}`, |
| 83 | }, |
| 84 | }); |
| 85 | |
| 86 | if (!response.ok) { |
| 87 | throw new Error(`Could not create tunnel: ${response.status}`); |
| 88 | } |
| 89 | |
| 90 | const body = (await response.json()) as any; |
| 91 | |
| 92 | return body.id; |
| 93 | } |
| 94 | |
| 95 | connectUrl(id: string): string { |
| 96 | return `${id}.${this.host}`; |