Commit
Load .env at server boot
commit
eaab0c6
2 changed files with +4 and −0
Jump to a changed file
- .gitignore +1 −0
- server/index.ts +3 −0
modified .gitignore +1 −0
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | node_modules |
| 2 | 2 | dist |
| 3 | +.env | |
| 3 | 4 | dist-ssr |
| 4 | 5 | *.local |
| 5 | 6 | data/sessions |
modified server/index.ts +3 −0
| @@ -1,5 +1,8 @@ | ||
| 1 | +import { existsSync } from 'node:fs' | |
| 1 | 2 | import { buildApp } from './app' |
| 2 | 3 | |
| 4 | +if (existsSync('.env')) process.loadEnvFile('.env') | |
| 5 | + | |
| 3 | 6 | const PORT = Number(process.env.PORT ?? 3001) |
| 4 | 7 | |
| 5 | 8 | async function main() { |