You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli)!: default dev/start port to 8080 instead of 3000 (#97)
* feat(cli)!: default dev/start port to 8080 instead of 3000
Change the fallback port in `webjs dev` / `webjs start` from 3000 to
8080 (process.env.PORT still wins, so deploys that inject PORT are
unaffected). 3000 is heavily contested locally (Next.js, CRA, Express,
Flask all default there); 8080 collides less for the scaffolded-app
experience.
Also updates the OAuth redirect's no-request fallback origin in
auth.js from localhost:3000 to localhost:8080 so dev OAuth URLs match
the new default.
Scaffolded apps pick this up for free: their package.json scripts stay
`webjs dev` / `webjs start` (no --port), so they inherit the new
default with zero template changes and full cross-platform behavior.
BREAKING: existing apps that relied on the implicit 3000 default will
now serve on 8080 locally after upgrading @webjsdev/cli. Set PORT=3000
or pass --port 3000 to keep the old port.
* docs: update default-port references from 3000 to 8080
Sweep docs, scaffold templates, and package READMEs to reflect the new
8080 default (getting-started, configuration, deployment, websockets,
backend-only, server-actions pages; scaffold .env.example + CONVENTIONS;
scaffold success message; cli/create-webjs/server READMEs; agent-docs;
root README quickstart). Word-boundary match preserves the 30000ms
interval example in the controllers page. The blog's own .env.example
port is left to the dev-ports change.
* fix(server): default startServer port to 8080, matching the CLI
startServer's own `opts.port ?? 3000` fallback was missed when the CLI
default moved to 8080. The CLI always passes an explicit port, so this
only affected programmatic startServer callers and embedders, but it
left an inconsistent 3000 default. Align it with the new 8080 default.
<p>The <code>json()</code> helper reads the <code>Accept</code> header. If the client sent <code>Accept: application/vnd.webjs+json</code> (as <code>richFetch</code> does), the response is encoded with the webjs serializer. Otherwise, plain <code>application/json</code>. The <code>Vary: Accept</code> header is set automatically.</p>
208
208
<p>For reading request bodies with the same content negotiation, use <code>readBody(req)</code> from <code>@webjsdev/server</code>.</p>
<li><strong>Dev:</strong> chokidar watches your source tree and triggers live reload via SSE. TypeScript files are served with <code>Cache-Control: no-cache</code>. Errors include full stack traces. No compression.</li>
<p>webjs includes a minimal logger that writes structured JSON in production and human-readable lines in development:</p>
79
79
<pre># Dev output:
80
-
[webjs] webjs dev server ready on http://localhost:3000
80
+
[webjs] webjs dev server ready on http://localhost:8080
81
81
82
82
# Prod output (one JSON line per event):
83
-
{"level":"info","msg":"webjs prod server ready on http://localhost:3000","time":"2026-01-15T10:30:00.000Z"}</pre>
83
+
{"level":"info","msg":"webjs prod server ready on http://localhost:8080","time":"2026-01-15T10:30:00.000Z"}</pre>
84
84
<p>Replace it with your own logger by passing any object with <code>info</code>, <code>warn</code>, and <code>error</code> methods to <code>createRequestHandler</code>:</p>
85
85
<pre>import { createRequestHandler } from '@webjsdev/server';
<p>webjs reads the following environment variables:</p>
163
163
<ul>
164
-
<li><strong>PORT</strong>: server port (default: 3000). Overridden by <code>--port</code> CLI flag.</li>
164
+
<li><strong>PORT</strong>: server port (default: 8080). Overridden by <code>--port</code> CLI flag.</li>
165
165
<li><strong>NODE_ENV</strong>: not directly used by webjs (it uses the <code>dev</code> flag from the CLI command), but your app code and dependencies may read it.</li>
166
166
</ul>
167
167
<p>For app-specific environment variables, use <code>process.env</code> in server-side code (pages, server actions, middleware, API routes). These are never exposed to the client.</p>
@@ -184,8 +184,8 @@ RUN npm ci --omit=dev
184
184
# Copy app source as-is; the server serves it directly
Copy file name to clipboardExpand all lines: docs/app/docs/getting-started/page.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ npm i -g @webjsdev/cli
20
20
# scaffold a new app
21
21
webjs create my-app
22
22
cd my-app && npm run dev
23
-
# → http://localhost:3000</pre>
23
+
# → http://localhost:8080</pre>
24
24
25
25
<p>Every scaffold ships with Prisma + SQLite wired up (<code>prisma/schema.prisma</code> with an example <code>User</code> model and <code>lib/prisma.server.ts</code> singleton). Run <code>npm run db:migrate</code> the first time to create <code>prisma/dev.db</code>.</p>
Copy file name to clipboardExpand all lines: examples/blog/CONVENTIONS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -209,7 +209,7 @@ variables control infrastructure (no config files needed):
209
209
|`AUTH_SECRET`| Required for auth JWT signing (32+ random chars) |
210
210
|`AUTH_GOOGLE_ID`| Google OAuth client ID (optional) |
211
211
|`AUTH_GITHUB_ID`| GitHub OAuth client ID (optional) |
212
-
|`PORT`| Server port (default: 3000) |
212
+
|`PORT`| Server port (default: 8080) |
213
213
|`WEBJS_PUBLIC_*`| Any env var starting with this prefix is exposed to the browser as `process.env.WEBJS_PUBLIC_X`. Components can read it directly. No build step, no transform. Use for API base URLs, Stripe publishable keys, analytics IDs, anything that is intended to be visible client-side. |
214
214
215
215
**Server-only by default.** Any env var without the `WEBJS_PUBLIC_` prefix never reaches the browser. Reading `process.env.DATABASE_URL` from a component returns `undefined`, the same as a typo. The prefix is fail-closed: secrets cannot accidentally leak.
0 commit comments