Deploy a Node.js API, worker or one-off script
Start a Node.js project with the correct entry file, check the example API over HTTPS, and run a finite script from the Runs page.
Match the profile to the process
Open Node.js 호스팅 and choose HTTP 앱 또는 API for a process serving requests. Choose 상시 실행 워커 for an event consumer, or 일회성 Node.js 스크립트 for a command that produces a result and exits. The examples below are independent projects. Put each in the matching deployment.
Serve the example API
- Download the Node.js API archive and upload it at the root in Files. Confirm
index.mjsappears there. - Set
MAIN_FILE→index.mjsin Variables. This example uses Node’s built-in HTTP server, so it needs no install command. - Start it, wait for
Node.js API listeningin Console and open the HTTPS address in Settings. A GET request to/returns the JSON below.
{"service":"node-api","status":"ok"}The API listens on 0.0.0.0 및 SERVER_PORT. If your own app starts but the URL fails, follow diagnosing an unreachable Node.js API.
Deploy your own package
Upload your entry file, package manifest and lockfile, or GitHub 브랜치를 연결해요. In Files, check that the project root contains the package used by your start command. A wrapper directory from an archive can move the actual package one level down.
Set MAIN_FILE when you start a single file. Set RUN_COMMAND when your package controls startup. A custom command handles its own dependencies and build steps. For an npm project with a lockfile and a start script, npm ci && npm start installs before starting. Add a build step only if your project defines one. Store private API keys in 변수.
Check background and finite work
이 worker example runs index.js and prints a timestamped heartbeat once a minute. Start it, watch two heartbeats in Console, then restart and look for a new first timestamp.
For the one-off example, select the job profile and use index.js. Start the deployment to bring up its runner. Open Runs and select 지금 실행. Look for a successful exit and JSON containing node-report. 설정할 항목은 JOB_TIMEOUT_SECONDS and restart to change how long an individual run may take.