docs: fix example secrets

This commit is contained in:
2026-09-26 15:26:00 -04:00
parent b304d8ac9f
commit ee8b8f239d
5 changed files with 77 additions and 28 deletions
+23 -5
View File
@@ -6,7 +6,7 @@ This is the SvelteKit frontend for SharpbinV3.
### Prerequisites
- Node.js (v20 or newer recommended)
- Node.js 24
- npm
### Installation
@@ -19,11 +19,12 @@ npm install
### Environment Configuration
The frontend requires an environment variable to point to the backend API. Create a `.env` file in this directory or set the variable in your environment:
The frontend defaults to the backend at `http://localhost:5050`. SvelteKit loads `.env` files during development, but `vite.config.ts` reads shell environment variables directly for its proxy and allowed hosts:
- `VITE_API_URL`: The URL of the backend API (e.g., `http://localhost:8080`).
- `VITE_ALLOWED_HOSTS`: A comma separated list of allowed hosts (e.g., `localhost,sharpbin.whoswhip.dev`)
- `VIEW_INTERNAL_API_KEY`: Enforces views to be counted/recorded only by the frontend, if set it needs to be the same for both backend and frontend.
- `VITE_API_URL`: The backend URL reachable from the frontend server. Export this in the shell when changing the development backend URL so the Vite proxy and server-side requests use the same value.
- `VITE_ALLOWED_HOSTS`: A comma-separated list of hosts for Vite dev/preview. Export this in the shell before starting Vite. It does not configure the production Node server.
In development, the frontend uses a fixed internal view-recording key matching `appsettings.Development.json`. It ignores `VIEW_INTERNAL_API_KEY` and `View_HMAC_Internal_API_Key` while `NODE_ENV=development`.
### Running in Development
@@ -35,6 +36,23 @@ npm run dev
The frontend will be available at http://localhost:5173.
### Running in Production
Docker Compose loads `frontend.env` and runs the built Node server on port 5173. Set these runtime variables:
- `VITE_API_URL`: Backend URL. Compose sets `http://backend:8080` directly, overriding `frontend.env`.
- `ORIGIN`: Public frontend URL, such as `https://example.com` or `http://localhost:5173` for local Docker testing.
- `VIEW_INTERNAL_API_KEY`: Same generated value as the backend's `PasteSettings__View_Internal_API_Key`. If unset, the frontend reads `View_HMAC_Internal_API_Key`; it does not read the backend setting name.
For a standalone Node deployment, `.env` is not loaded automatically. Build the frontend, then load your environment file explicitly:
```bash
npm run build
node --env-file=.env build
```
Set `PORT=5173` in that file to use the same port as Docker; the Node adapter otherwise defaults to port 3000. See the [Node adapter documentation](https://svelte.dev/docs/kit/adapter-node#Environment-variables) for runtime configuration.
## Script Reference
- `npm run dev`: Start the Vite development server.