traforo 0.3.0 → 0.4.0

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.
package/README CHANGED
@@ -111,6 +111,29 @@ instructions to pass the password as a cookie:
111
111
  WebSocket upgrade requests without the correct cookie are rejected with
112
112
  close code 4013.
113
113
 
114
+ ## TRAFORO_URL ENVIRONMENT VARIABLE
115
+
116
+ When you run a command after `--`, traforo injects `TRAFORO_URL` into the
117
+ child process environment with the full public tunnel URL:
118
+
119
+ TRAFORO_URL=https://{tunnel-id}-tunnel.traforo.dev
120
+
121
+ Your app can read it directly:
122
+
123
+ const baseUrl = process.env.TRAFORO_URL
124
+
125
+ To remap it to a custom env var your app already uses, prefix the command:
126
+
127
+ traforo -p 3000 -- sh -c 'APP_URL=$TRAFORO_URL exec node server.js'
128
+ traforo -p 3000 -- sh -c 'NEXT_PUBLIC_URL=$TRAFORO_URL exec next dev'
129
+ traforo -p 3000 -- sh -c 'VITE_BASE_URL=$TRAFORO_URL exec vite'
130
+
131
+ Or set it in your .env / startup script and let traforo override only
132
+ `TRAFORO_URL`, reading it where needed:
133
+
134
+ // next.config.js
135
+ const baseUrl = process.env.APP_URL || process.env.TRAFORO_URL || 'http://localhost:3000'
136
+
114
137
  ## HOW IT WORKS
115
138
 
116
139
  1. Local client connects to Cloudflare Durable Object via WebSocket
@@ -330,6 +330,9 @@ export async function runTunnel(options) {
330
330
  }
331
331
  }
332
332
  let child = null;
333
+ // Compute tunnel URL early so it can be injected into the child env
334
+ const baseDomain = options.baseDomain || 'traforo.dev';
335
+ const tunnelUrl = `https://${tunnelId}-tunnel.${baseDomain}`;
333
336
  // If command provided, spawn child process with PORT env
334
337
  if (options.command && options.command.length > 0) {
335
338
  const cmd = options.command[0];
@@ -347,6 +350,7 @@ export async function runTunnel(options) {
347
350
  env: {
348
351
  ...process.env,
349
352
  ...(port ? { PORT: String(port) } : {}),
353
+ TRAFORO_URL: tunnelUrl,
350
354
  // Disable clear/animations for common tools without lying about CI
351
355
  FORCE_COLOR: '1',
352
356
  VITE_CLS: 'false',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "traforo",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "HTTP tunnel via Cloudflare Durable Objects and WebSockets. Edge caching and password protection.",
5
5
  "type": "module",
6
6
  "license": "MIT",