@farm.js/create-app 0.1.51-beta.2 → 0.1.51-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm.js/create-app",
3
- "version": "0.1.51-beta.2",
3
+ "version": "0.1.51-beta.3",
4
4
  "description": "Create a new FARMJS application",
5
5
  "keywords": [
6
6
  "@farm.js/create-app",
@@ -11,7 +11,7 @@
11
11
  "type-check": "tsc --noEmit"
12
12
  },
13
13
  "dependencies": {
14
- "@farm.js/core": "0.1.51-beta.2",
14
+ "@farm.js/core": "0.1.51-beta.3",
15
15
  "@farm.js/preact": "0.1.0-beta.36",
16
16
  "@fontsource-variable/geist": "5.3.0",
17
17
  "@fontsource-variable/geist-mono": "5.3.0",
@@ -19,8 +19,8 @@
19
19
  "zod": "4.6.7"
20
20
  },
21
21
  "devDependencies": {
22
- "@farm.js/cli": "0.1.51-beta.2",
23
- "@farm.js/devtools": "0.1.51-beta.2",
22
+ "@farm.js/cli": "0.1.51-beta.3",
23
+ "@farm.js/devtools": "0.1.51-beta.3",
24
24
  "@tailwindcss/vite": "^4.3.3",
25
25
  "tailwindcss": "^4.0.0",
26
26
  "typescript": "^5.3.3"
@@ -10,7 +10,7 @@
10
10
  "type-check": "tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "@farm.js/core": "0.1.51-beta.2",
13
+ "@farm.js/core": "0.1.51-beta.3",
14
14
  "@farm.js/solid": "0.1.0-beta.33",
15
15
  "@fontsource-variable/geist": "5.3.0",
16
16
  "@fontsource-variable/geist-mono": "5.3.0",
@@ -18,8 +18,8 @@
18
18
  "zod": "4.6.7"
19
19
  },
20
20
  "devDependencies": {
21
- "@farm.js/cli": "0.1.51-beta.2",
22
- "@farm.js/devtools": "0.1.51-beta.2",
21
+ "@farm.js/cli": "0.1.51-beta.3",
22
+ "@farm.js/devtools": "0.1.51-beta.3",
23
23
  "@tailwindcss/vite": "^4.3.3",
24
24
  "tailwindcss": "^4.0.0",
25
25
  "typescript": "^5.3.3"
@@ -11,7 +11,7 @@
11
11
  "type-check": "svelte-check --tsconfig ./tsconfig.json"
12
12
  },
13
13
  "dependencies": {
14
- "@farm.js/core": "0.1.51-beta.2",
14
+ "@farm.js/core": "0.1.51-beta.3",
15
15
  "@farm.js/svelte": "0.1.0-beta.35",
16
16
  "@fontsource-variable/geist": "5.3.0",
17
17
  "@fontsource-variable/geist-mono": "5.3.0",
@@ -19,8 +19,8 @@
19
19
  "zod": "4.6.7"
20
20
  },
21
21
  "devDependencies": {
22
- "@farm.js/cli": "0.1.51-beta.2",
23
- "@farm.js/devtools": "0.1.51-beta.2",
22
+ "@farm.js/cli": "0.1.51-beta.3",
23
+ "@farm.js/devtools": "0.1.51-beta.3",
24
24
  "@tailwindcss/vite": "^4.3.3",
25
25
  "svelte-check": "4.7.5",
26
26
  "tailwindcss": "^4.0.0",
@@ -10,7 +10,7 @@
10
10
  "type-check": "vue-tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "@farm.js/core": "0.1.51-beta.2",
13
+ "@farm.js/core": "0.1.51-beta.3",
14
14
  "@farm.js/vue": "0.1.0-beta.33",
15
15
  "@fontsource-variable/geist": "5.3.0",
16
16
  "@fontsource-variable/geist-mono": "5.3.0",
@@ -18,8 +18,8 @@
18
18
  "zod": "4.6.7"
19
19
  },
20
20
  "devDependencies": {
21
- "@farm.js/cli": "0.1.51-beta.2",
22
- "@farm.js/devtools": "0.1.51-beta.2",
21
+ "@farm.js/cli": "0.1.51-beta.3",
22
+ "@farm.js/devtools": "0.1.51-beta.3",
23
23
  "@tailwindcss/vite": "^4.3.3",
24
24
  "tailwindcss": "^4.0.0",
25
25
  "typescript": "^5.3.3",
@@ -12,8 +12,8 @@
12
12
  "type-check": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@farm.js/auth": "0.1.51-beta.2",
16
- "@farm.js/core": "0.1.51-beta.2",
15
+ "@farm.js/auth": "0.1.51-beta.3",
16
+ "@farm.js/core": "0.1.51-beta.3",
17
17
  "@farming-labs/docs": "0.2.130",
18
18
  "@farming-labs/farmjs": "0.2.130",
19
19
  "@farming-labs/theme": "0.2.130",
@@ -24,8 +24,8 @@
24
24
  "react-dom": "^19.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@farm.js/cli": "0.1.51-beta.2",
28
- "@farm.js/devtools": "0.1.51-beta.2",
27
+ "@farm.js/cli": "0.1.51-beta.3",
28
+ "@farm.js/devtools": "0.1.51-beta.3",
29
29
  "@tailwindcss/vite": "^4.3.3",
30
30
  "@types/node": "22.20.1",
31
31
  "@types/react": "^19.0.0",
@@ -10,7 +10,7 @@
10
10
  "type-check": "tsc --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "@farm.js/core": "0.1.51-beta.2",
13
+ "@farm.js/core": "0.1.51-beta.3",
14
14
  "@farming-labs/docs": "0.2.130",
15
15
  "@farming-labs/farmjs": "0.2.130",
16
16
  "@farming-labs/theme": "0.2.130",
@@ -20,8 +20,8 @@
20
20
  "react-dom": "^19.0.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@farm.js/cli": "0.1.51-beta.2",
24
- "@farm.js/devtools": "0.1.51-beta.2",
23
+ "@farm.js/cli": "0.1.51-beta.3",
24
+ "@farm.js/devtools": "0.1.51-beta.3",
25
25
  "@tailwindcss/vite": "^4.3.3",
26
26
  "@types/react": "^19.0.0",
27
27
  "@types/react-dom": "^19.0.0",
@@ -1,4 +1,5 @@
1
- BETTER_AUTH_URL=http://localhost:3000
1
+ # Required in production. Leave unset in development to sign in from any dev port or device.
2
+ # BETTER_AUTH_URL=https://app.example.com
2
3
  # Generate with: openssl rand -base64 32
3
4
  BETTER_AUTH_SECRET=
4
5
  DATABASE_URL=postgresql://user:password@your-neon-pooler-host/database?sslmode=require
@@ -62,10 +62,16 @@ FARMJS owns the catch-all integration route, so the starter does not need a manu
62
62
 
63
63
  | Variable | Purpose |
64
64
  | -------------------- | ----------------------------------------- |
65
- | `BETTER_AUTH_URL` | Public origin used by Better Auth |
65
+ | `BETTER_AUTH_URL` | Public origin, required in production |
66
66
  | `BETTER_AUTH_SECRET` | Secret used to sign and encrypt auth data |
67
67
  | `DATABASE_URL` | Pooled Postgres connection string |
68
68
 
69
+ Without `BETTER_AUTH_URL`, `farm dev` trusts the origin it is serving the request on when the host
70
+ is `localhost`, `*.localhost`, or an IP address, so another port, the Android emulator's
71
+ `http://10.0.2.2:<port>`, and LAN devices under `farm dev --host` can sign in. A page on another
72
+ origin is still rejected. Set `BETTER_AUTH_URL` for a custom dev hostname; production trusts only
73
+ that origin.
74
+
69
75
  Never commit `.env.local` or expose the database connection string.
70
76
 
71
77
  ## Deployment note
@@ -12,8 +12,8 @@
12
12
  "type-check": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@farm.js/better-auth": "0.1.51-beta.2",
16
- "@farm.js/core": "0.1.51-beta.2",
15
+ "@farm.js/better-auth": "0.1.51-beta.3",
16
+ "@farm.js/core": "0.1.51-beta.3",
17
17
  "@farming-labs/docs": "0.2.130",
18
18
  "@farming-labs/farmjs": "0.2.130",
19
19
  "@farming-labs/theme": "0.2.130",
@@ -26,8 +26,8 @@
26
26
  "react-dom": "^19.0.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@farm.js/cli": "0.1.51-beta.2",
30
- "@farm.js/devtools": "0.1.51-beta.2",
29
+ "@farm.js/cli": "0.1.51-beta.3",
30
+ "@farm.js/devtools": "0.1.51-beta.3",
31
31
  "@tailwindcss/vite": "^4.3.3",
32
32
  "@types/node": "22.20.1",
33
33
  "@types/pg": "8.20.0",
@@ -1,10 +1,18 @@
1
+ import { isIP } from "node:net";
1
2
  import { betterAuth } from "better-auth";
2
3
  import { Pool, type PoolConfig } from "pg";
3
4
 
4
- const authBaseUrl = process.env.BETTER_AUTH_URL ?? "http://localhost:3000";
5
+ const isProduction = process.env.NODE_ENV === "production";
6
+ const authBaseUrl = process.env.BETTER_AUTH_URL;
5
7
  const databaseUrl = process.env.DATABASE_URL;
6
8
  const secret = process.env.BETTER_AUTH_SECRET;
7
9
 
10
+ if (isProduction && !authBaseUrl) {
11
+ throw new Error(
12
+ "BETTER_AUTH_URL is required in production. Set it to the app's public origin, such as https://app.example.com.",
13
+ );
14
+ }
15
+
8
16
  if (!databaseUrl) {
9
17
  throw new Error("DATABASE_URL is required. Add your pooled Postgres connection string.");
10
18
  }
@@ -25,7 +33,7 @@ if (databaseConnection.searchParams.get("sslmode") === "require") {
25
33
  const poolConfig: PoolConfig & { enableChannelBinding: boolean } = {
26
34
  connectionString: databaseConnection.toString(),
27
35
  enableChannelBinding,
28
- max: process.env.NODE_ENV === "production" ? 5 : 2,
36
+ max: isProduction ? 5 : 2,
29
37
  idleTimeoutMillis: 30_000,
30
38
  connectionTimeoutMillis: 10_000,
31
39
  allowExitOnIdle: true,
@@ -33,14 +41,30 @@ const poolConfig: PoolConfig & { enableChannelBinding: boolean } = {
33
41
 
34
42
  export const authDatabase = new Pool(poolConfig);
35
43
 
44
+ /**
45
+ * Without BETTER_AUTH_URL, `farm dev` trusts the origin it is serving the
46
+ * request on, so another port, the Android emulator's 10.0.2.2, or a LAN
47
+ * device under `farm dev --host` can sign in. Only localhost, *.localhost, and
48
+ * IP addresses qualify, so a DNS-rebinding hostname is never trusted, and a
49
+ * page on another origin is still rejected.
50
+ */
51
+ export function devServerOrigin(request?: Request): string[] {
52
+ if (!request) return [];
53
+ const url = new URL(request.url);
54
+ const hostname = url.hostname.replace(/^\[|\]$/g, "");
55
+ const local = hostname === "localhost" || hostname.endsWith(".localhost") || isIP(hostname) !== 0;
56
+ return local ? [url.origin] : [];
57
+ }
58
+
36
59
  export const auth = betterAuth({
37
60
  appName: "FARMJS Better Auth Starter",
38
- baseURL: authBaseUrl,
61
+ // Development without BETTER_AUTH_URL uses the port farm.config.ts pins.
62
+ baseURL: authBaseUrl ?? "http://localhost:3000",
39
63
  database: authDatabase,
40
64
  emailAndPassword: {
41
65
  enabled: true,
42
66
  minPasswordLength: 8,
43
67
  },
44
68
  secret,
45
- trustedOrigins: [new URL(authBaseUrl).origin],
69
+ trustedOrigins: authBaseUrl ? [new URL(authBaseUrl).origin] : devServerOrigin,
46
70
  });
@@ -11,8 +11,8 @@
11
11
  "type-check": "tsc --noEmit"
12
12
  },
13
13
  "dependencies": {
14
- "@farm.js/core": "0.1.51-beta.2",
15
- "@farm.js/react": "0.1.0-beta.35",
14
+ "@farm.js/core": "0.1.51-beta.3",
15
+ "@farm.js/react": "0.1.0-beta.36",
16
16
  "@farming-labs/docs": "0.2.130",
17
17
  "@farming-labs/farmjs": "0.2.130",
18
18
  "@farming-labs/theme": "0.2.130",
@@ -22,8 +22,8 @@
22
22
  "react-dom": "19.2.8"
23
23
  },
24
24
  "devDependencies": {
25
- "@farm.js/cli": "0.1.51-beta.2",
26
- "@farm.js/devtools": "0.1.51-beta.2",
25
+ "@farm.js/cli": "0.1.51-beta.3",
26
+ "@farm.js/devtools": "0.1.51-beta.3",
27
27
  "@playwright/test": "^1.52.0",
28
28
  "@tailwindcss/vite": "^4.3.3",
29
29
  "@types/node": "22.20.1",