The Sprinter IT Hub frontend talks to a Google Apps Script Web App for Phase 1.5 backend connectivity. The endpoint URL is provided at build time through an environment variable so it can be rotated or swapped per environment without changing application code.
| Name | Scope | Purpose |
|---|---|---|
VITE_GOOGLE_APPS_SCRIPT_URL |
Client (Vite) | Deployed Apps Script Web App endpoint that receives POST requests from the frontend. |
The VITE_ prefix is required. Vite only exposes variables starting with
VITE_ to browser code via import.meta.env.
- Open the Apps Script project in your Google account.
- Click Deploy → New deployment.
- Select type Web app.
- Set:
- Execute as: Me
- Who has access: Anyone with the link (or restrict as required)
- Click Deploy and copy the generated
/execURL. - Save the URL somewhere secure. Anyone with this URL can call the endpoint, so treat it as a shared credential.
Any time the script is redeployed under a new version, the URL may change.
Update .env.local and restart the dev server after each redeploy.
-
Copy the example file to a local override:
cp .env.example .env.local
-
Paste the deployed URL:
VITE_GOOGLE_APPS_SCRIPT_URL=https://script.google.com/macros/s/xxxxxxxxxxxxxxxxxxxxxxxx/exec
-
Restart the dev server so Vite picks up the new value.
.env.local is git-ignored via the *.local rule in .gitignore and must
never be committed.
All backend traffic goes through src/services/googleAppsScript.ts. No
component fetches the endpoint directly.
- Each request is a
POSTwithContent-Type: application/jsonandAccept: application/json. - The request body always has the shape
{ action, payload }so a single Apps ScriptdoPosthandler can route by action name. - Every service function returns a discriminated
ApiResult<T>:{ success: true, data }on success.{ success: false, message, error? }on missing configuration, non-2xx responses, or network failures.
- If
VITE_GOOGLE_APPS_SCRIPT_URLis undefined the service short-circuits and returns{ success: false, message: "Google Apps Script endpoint has not been configured." }. The UI never crashes.
Supported actions today:
| Function | Action string |
|---|---|
submitDocumentationRequest(data) |
submitDocumentationRequest |
getDocumentationRequests() |
getDocumentationRequests |
updateDocumentationRequestStatus(id, status) |
updateDocumentationRequestStatus |
submitArticleFeedback(data) |
submitArticleFeedback |
Add new actions by extending the AppsScriptAction union and exporting a
new wrapper function. No other files need to change.
- Never commit
.env.local. The*.localrule already excludes it. - Never hardcode the endpoint URL in application code or documentation.
- Treat the Web App URL as sensitive; rotate the deployment if it leaks.
- Because the variable is
VITE_-prefixed it ships to the browser bundle. Do not put private API keys or service-account credentials in this variable. The Apps Script itself should enforce authorization.