Repository navigation
fix: bind example servers to localhost by default - #19
Conversation
Samy-O7
left a comment
There was a problem hiding this comment.
Approving. Checked at fdcad8e:
- All seven sidecars listen on
127.0.0.1by default, withHOSTto override: node-ts, python, ruby, go, java and dotnet in code, and php through thephp -S 127.0.0.1:3022commands in both READMEs. - The Dockerfiles set
HOST=0.0.0.0(php'sCMDuses0.0.0.0directly), so the containers stay reachable, and Compose publishes every port, including the test fake API on 3099, on127.0.0.1only. client/web-nextneeds no change: its checkpoint and event calls come from client components in the browser, so it never relays requests to a sidecar.
Optional, not blocking: node-ts uses cors(), which allows any origin, so a web page open in the developer's browser can still call the sidecar on localhost. Limiting it to the web-next origin (http://localhost:3000 by default, overridable with an env var) would close that, and the server/README line about allowing any origin could then describe the restricted setup.
82f2f1b to
91dd5f0
Compare
|
@Samy-O7 Added in 91dd5f0: node-ts only allows CORS from http://localhost:3000, overridable with CORS_ORIGIN (listed in node-ts/.env.example). The server README now explains when to set it. I also removed app.options("*", cors()), since app.use(cors(...)) already handles preflights. |
Samy-O7
left a comment
There was a problem hiding this comment.
Re-approving at 91dd5f0. I checked the CORS commit by running node-ts against server/tests/fake-composer-api.mjs:
- Preflights now get
Access-Control-Allow-Originset to the configured origin (http://localhost:3000by default) instead of*, so other origins can't read responses.CORS_ORIGINoverrides it. - JSON checkpoint and event calls from the web-next origin still reach the API.
- Cross-site
text/plain, urlencoded and multipart posts (the ones browsers send without a preflight) reach nothing, as before:/checkpointreturns 400 and/eventsends nothing. - Dropping
app.options("*", cors())is fine, sinceapp.use(cors(...))already answers preflights.
Optional nit: client/web-next/README.md suggests npm run dev -- --port <port>. A line there about setting CORS_ORIGIN in server/node-ts/.env would save a CORS error for anyone who changes the port.
Samy-O7
left a comment
There was a problem hiding this comment.
Re-approving at 1273643. Checked the two new commits:
- The web-next README now says to set
CORS_ORIGINinserver/node-ts/.envwhen running on another port, which matches how node-ts reads it. - In
client/web-next/package-lock.json, onlynext,@next/env, the nine@next/swc-*binaries andfollow-redirectschange. Every integrity hash matches the registry, andnext15.5.28 was published with provenance. - The web-next check now passes
npm audit --omit=dev --audit-level=high(only the twouuidmoderates from@dodgeball/trust-sdk-clientremain) and builds on Next.js 15.5.28.
For the record, web-next wasn't exposed to either of today's Next.js advisories: it has no Server Actions and already resolved sharp 0.35.5.
Changes
127.0.0.1by default, so only the local machine can reach them. SetHOST=0.0.0.0to accept connections from other machines.HOST=0.0.0.0so the server is reachable inside the container, and Docker Compose publishes each port on127.0.0.1only.ASPNETCORE_URLSfromHOSTinstead of hard-coding0.0.0.0.127.0.0.1and documentHOST.http://localhost:3000), overridable withCORS_ORIGIN. The web-next README explains setting it when running on a custom port.next15.5.28 andfollow-redirects1.16.1 to clear high and criticalnpm auditadvisories.