mirror of
https://github.com/farcasclaudiu/learn-build-apps-copilot-agent.git
synced 2026-06-22 07:01:37 +03:00
36 lines
1.1 KiB
Markdown
36 lines
1.1 KiB
Markdown
## Step 4: Wire API hosting for the multi-tier application
|
|
|
|
In this step, you will finalize API hosting for your **multi-tier application**:
|
|
|
|
- Keep backend API on port `8000`.
|
|
- Build Codespaces-aware API URL behavior using `$CODESPACE_NAME`.
|
|
- Validate endpoints with `curl`.
|
|
|
|
### :keyboard: Activity: Configure API base URL and host support
|
|
|
|
> 
|
|
>
|
|
> ```prompt
|
|
> Let's configure the Node.js API for Codespaces and localhost.
|
|
>
|
|
> - Backend runs on port 8000
|
|
> - Build API base URL with $CODESPACE_NAME when available:
|
|
> https://$CODESPACE_NAME-8000.app.github.dev
|
|
> - Keep localhost support when $CODESPACE_NAME is not set
|
|
> - Verify /api/users and /api/activities with curl
|
|
> ```
|
|
|
|
1. Commit and push your changes to `build-octofit-app`.
|
|
|
|
1. Wait for Mona to validate and share the next step.
|
|
|
|
<details>
|
|
<summary>Having trouble? 🤷</summary><br/>
|
|
|
|
Verify `octofit-tracker/backend/src/server.ts` includes:
|
|
|
|
- `CODESPACE_NAME`
|
|
- `-8000.app.github.dev`
|
|
|
|
</details>
|