localgate 0.6.0 → 0.6.1

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.md CHANGED
@@ -278,12 +278,24 @@ their own names without either name being in the repository:
278
278
 
279
279
  With that file present, `myapp` in mode `lan` also answers on `myapp.dev.example.com`, while mode
280
280
  `internet` additionally answers on `pub-myapp.example.com`. Browser-facing
281
- environment variables (`NEXT_PUBLIC_*`, `*_PUBLIC_URL`, `AUTH_URL`, `NEXTAUTH_URL`) are rewritten from
281
+ environment variables (`NEXT_PUBLIC_*`, `*_PUBLIC_URL`) are rewritten from
282
282
  `.localhost` to the name selected by the current mode on the way into the dev server. Public URLs use
283
283
  HTTPS and never carry the proxy's internal LAN port. Server-side variables stay on `.localhost`.
284
284
  Node children get a lookup hook for that reserved suffix, so Fetch and the standard HTTP clients reach
285
285
  the local proxy even when the operating system resolver does not expand nested localhost names.
286
286
 
287
+ For Auth.js applications that serve several origins, omit `AUTH_URL` and `NEXTAUTH_URL` from the
288
+ application's development env files and launch environment, and configure `trustHost: true` or
289
+ `AUTH_TRUST_HOST=true`. Authentication can then follow each request's origin. Localgate sets
290
+ `X-Forwarded-Host` to the routed `Host`, including its port, and defaults `X-Forwarded-Proto` to `http`,
291
+ preserving a tunnel's single `http` or `https` value. Each origin keeps its own session cookie.
292
+
293
+ Localgate does not delete auth settings, set trust flags or intercept env-file loading. Explicit auth
294
+ URLs keep their configured hostname; as with other server URLs, a `.localhost` value receives the
295
+ proxy port. This replaces the earlier behavior that rewrote auth URLs to the LAN or public hostname.
296
+ Custom auth paths, cookie prefixes and older NextAuth server helpers remain application configuration.
297
+ See [docs/architecture/auth-origin.md](docs/architecture/auth-origin.md) for compatibility and restart steps.
298
+
287
299
  For reaching an app from outside the LAN, `localgate cloudflare-info` prints the exact prefixed DNS
288
300
  record and tunnel ingress entry. It prints them and stops: localgate holds no API token and sends
289
301
  nothing anywhere. In Atomix projects, use `axtoolsv2 expose <dir> off|network|internet`; AtomixToolsV2
@@ -17,6 +17,12 @@ export class LocalgateHeaderRewrite
17
17
 
18
18
  static apply(requestUrl: string, headers: IncomingHttpHeaders, requestHost: string, canonicalName: string): void
19
19
  {
20
+ // Routing has already validated Host. Auth libraries prefer forwarded headers, so an unrelated
21
+ // forwarded host must not override it. A TLS-terminating tunnel supplies the original protocol.
22
+ headers["x-forwarded-host"] = requestHost;
23
+ if (headers["x-forwarded-proto"] != "http" && headers["x-forwarded-proto"] != "https")
24
+ headers["x-forwarded-proto"] = "http";
25
+
20
26
  if (!LocalgateHeaderRewrite.isInternalPath(requestUrl)) return;
21
27
 
22
28
  const requestHostname = LocalgateHeaderRewrite.hostnameOf(requestHost);
@@ -15,7 +15,6 @@ import { LocalgateUrl } from "../proxy/localgateUrl.ts";
15
15
  export class LocalgateEnvRewrite
16
16
  {
17
17
  private static readonly localSuffixConst = ".localhost";
18
- private static readonly browserFacingNamesConst = ["AUTH_URL", "NEXTAUTH_URL"];
19
18
 
20
19
  static apply(env: NodeJS.ProcessEnv, mode: LocalgateMode, machine: LocalgateMachineSettings | null,
21
20
  proxyPort: number): NodeJS.ProcessEnv
@@ -37,9 +36,7 @@ export class LocalgateEnvRewrite
37
36
 
38
37
  static isBrowserFacing(key: string): boolean
39
38
  {
40
- return key.startsWith("NEXT_PUBLIC_")
41
- || key.endsWith("_PUBLIC_URL")
42
- || LocalgateEnvRewrite.browserFacingNamesConst.includes(key);
39
+ return key.startsWith("NEXT_PUBLIC_") || key.endsWith("_PUBLIC_URL");
43
40
  }
44
41
 
45
42
  // Substitutes the authority only, and by string replacement rather than URL.toString(), so a value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "localgate",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Stable names for local dev servers: one port 80 multiplexed by Host, plus an API that can restart a dev server owned by your editor.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",