fix(startup): load .env with dotenv parser
This commit is contained in:
@@ -62,6 +62,7 @@
|
|||||||
|
|
||||||
- `start.sh` is intentionally ignored by Git (`.gitignore`) so server secrets are not committed.
|
- `start.sh` is intentionally ignored by Git (`.gitignore`) so server secrets are not committed.
|
||||||
- Use `start.example.sh` as the tracked template and keep real credentials in environment variables (or `.env` on the server).
|
- Use `start.example.sh` as the tracked template and keep real credentials in environment variables (or `.env` on the server).
|
||||||
|
- Startup scripts parse `.env` with the `dotenv` parser (not shell `source`), so values containing spaces are handled safely.
|
||||||
- Startup scripts run patch helpers before boot (`scripts/patch-lightningcss.mjs`, `scripts/patch-endpoint-media-scope.mjs`, `scripts/patch-endpoint-files-upload-route.mjs`).
|
- Startup scripts run patch helpers before boot (`scripts/patch-lightningcss.mjs`, `scripts/patch-endpoint-media-scope.mjs`, `scripts/patch-endpoint-files-upload-route.mjs`).
|
||||||
- The media scope patch fixes a known upstream issue where file uploads can fail if the token scope is `create update delete` without explicit `media`.
|
- The media scope patch fixes a known upstream issue where file uploads can fail if the token scope is `create update delete` without explicit `media`.
|
||||||
- The files upload route patch fixes browser multi-upload by posting to `/files/upload` (session-authenticated) instead of direct `/media` calls without bearer token.
|
- The files upload route patch fixes browser multi-upload by posting to `/files/upload` (session-authenticated) instead of direct `/media` calls without bearer token.
|
||||||
+11
-4
@@ -3,11 +3,18 @@ set -eu
|
|||||||
|
|
||||||
cd /usr/local/indiekit
|
cd /usr/local/indiekit
|
||||||
|
|
||||||
# Optional: load environment from local .env file.
|
# Optional: load environment from local .env file
|
||||||
|
# (dotenv syntax, supports spaces in values).
|
||||||
if [ -f .env ]; then
|
if [ -f .env ]; then
|
||||||
set -a
|
eval "$(${NODE_BIN:-/usr/local/bin/node} -e '
|
||||||
. ./.env
|
const fs = require("node:fs");
|
||||||
set +a
|
const dotenv = require("dotenv");
|
||||||
|
const parsed = dotenv.parse(fs.readFileSync(".env"));
|
||||||
|
for (const [key, value] of Object.entries(parsed)) {
|
||||||
|
const safe = String(value).split("\x27").join("\x27\"\x27\"\x27");
|
||||||
|
process.stdout.write(`export ${key}=\x27${safe}\x27\\n`);
|
||||||
|
}
|
||||||
|
')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
: "${SECRET:?SECRET is required}"
|
: "${SECRET:?SECRET is required}"
|
||||||
|
|||||||
Reference in New Issue
Block a user