Next.js app with an HTTPS sibling API
A Next.js 16 App Router app run with preset: next, next to a small Hono API, as an npm workspace. The page is a server component that fetches the API twice while it renders: through the API’s public_url over HTTPS, which works because devlanes sets NODE_EXTRA_CA_CERTS for the service, and through its url straight to the port.
Requirements
Section titled “Requirements”- devlanes, with
devlanes setuprun once - Node 22 or later
Run it
Section titled “Run it”cd web-next-appdevlanes startdevlanes start --no-ui prints the start as text:
example-next-app@0 (main): 2/2 readyready web http://127.0.0.1:20431 https://example-next-app.localhostready api http://127.0.0.1:20430 https://api.example-next-app.localhostOpen https://example-next-app.localhost. The page says This is lane 0 of example-next-app., lists the values devlanes gave the web service, and shows one card per API fetch with its result and time.
During a start
Section titled “During a start”- The first start of a lane runs the
installtask. Onenpm installat the workspace root installs both apps. apirunsnpm run devinapps/api(tsx watch src/index.ts) behind https://api.example-next-app.localhost.webrunsnpm run devinapps/web, a plainnext dev.preset: nextappends--port <port> --hostname 127.0.0.1after a--, because the package manager is npm, so the log showsnext dev --port 20431 --hostname 127.0.0.1. Without--hostnameNext would listen on0.0.0.0.- Each service is ready once its
/healthzanswers.webgets a 120 s timeout becausenext devcompiles each route on its first request.
API addresses
Section titled “API addresses”devlanes.yaml sets API_PUBLIC_URL (https://api.example-next-app.localhost) from ${{ services.api.public_url }} and API_URL (http://127.0.0.1:20430) from ${{ services.api.url }}, and apps/web/lib/env.ts reads them. The page fetches them one after the other. The first request goes through the devlanes proxy, so the API sees X-Forwarded-Host; the second goes straight to the port and the API sees no such header. Node trusts the proxy’s certificate because devlanes points NODE_EXTRA_CA_CERTS at its CA for every Node service. The example sets neither that variable nor NODE_TLS_REJECT_UNAUTHORIZED.
allowedDevOrigins
Section titled “allowedDevOrigins”The presets guide says to set allowedDevOrigins when Next warns about cross-origin dev requests. Next 16.4 allows *.localhost by default, so the page’s own requests pass. A request for a /_next/static/chunks/ file with Origin: https://example.invalid gets a 403, and the log prints Blocked cross-origin request to Next.js dev resource with the allowedDevOrigins line to add. A lane domain outside .localhost, such as one under the resolver strategy’s .test, needs that line.
Try next
Section titled “Try next”Start a second lane:
git worktree add ../examples-checkout -b feat/checkout, thencd ../examples-checkout/web-next-app && devlanes start. The new worktree is lane 1, with its own.next. Its page at https://example-next-app1.localhost saysThis is lane 1 of example-next-app., and both API cards report lane 1.Run a second lane from the same folder instead:
devlanes lane new --name example-next-app-review, thendevlanes start --lane example-next-app-review --env NEXT_DIST_DIR=.next/review.next devlocks its output folder, so without the variable the second one exits withAnother next dev server is already running.apps/web/next.config.tsreadsNEXT_DIST_DIR.devlanes url lslists both lanes:HOST TARGET PORT STATEexample-next-app.localhost -> example-next-app@0:web 20431 readyapi.example-next-app.localhost -> example-next-app@0:api 20430 readyexample-next-app1.localhost -> example-next-app@1:web 20551 readyapi.example-next-app1.localhost -> example-next-app@1:api 20550 readydevlanes env show web --explain | grep NODE_EXTRA_CA_CERTSprints the path ofca.pemin your devlanes home, with the layercontributor(the Node platform) instead ofserviceorglobal.Take the CA away:
devlanes restart web --env NODE_EXTRA_CA_CERTS=. Reload the page: the HTTPS card showsError: self-signed certificate in certificate chainwhile the direct card still answers.A plain
devlanes restart webkeeps the--envvalue.devlanes stop weband thendevlanes start webbring the CA back.Stop the API with
devlanes stop apiand reload. The HTTPS card showsHTTP 503 Service Unavailablefrom the proxy, and the direct cardError: connect ECONNREFUSED 127.0.0.1:20430.devlanes start apibrings both back.devlanes lane clean 0 --yesstops lane 0 and deletes its data and logs. Run it withexample-next-app-reviewfor the same-folder lane, or with1from the second worktree.
devlanes.yaml: theinstalltask, thewebservice withpreset: nextand both API addresses, and theapiservice.apps/web/app/: the root layout, the page (a server component), and route handlers for/laneand/healthz.apps/web/lib/:env.tsfor the environment,api.tsfor the fetch with its timeout.apps/web/next.config.ts:NEXT_DIST_DIRfor lanes that share a folder, andagentRules: false, which stopsnext devfrom writing anAGENTS.mdwhen a coding agent runs devlanes.apps/api/src/: the Hono API.