feat: add API_HOST env
This commit is contained in:
@@ -63,6 +63,9 @@ declare module 'fastify' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const port = Number.parseInt(process.env.API_PORT || '3000', 10);
|
const port = Number.parseInt(process.env.API_PORT || '3000', 10);
|
||||||
|
const host =
|
||||||
|
process.env.API_HOST ||
|
||||||
|
(process.env.NODE_ENV === 'production' ? '0.0.0.0' : 'localhost');
|
||||||
|
|
||||||
const startServer = async () => {
|
const startServer = async () => {
|
||||||
logger.info('Starting server');
|
logger.info('Starting server');
|
||||||
@@ -263,10 +266,7 @@ const startServer = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await fastify.listen({
|
await fastify.listen({ host, port });
|
||||||
host: process.env.NODE_ENV === 'production' ? '0.0.0.0' : 'localhost',
|
|
||||||
port,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Notify when keys expires
|
// Notify when keys expires
|
||||||
|
|||||||
@@ -744,6 +744,27 @@ Port for the API service to listen on.
|
|||||||
API_PORT=3000
|
API_PORT=3000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### API_HOST
|
||||||
|
|
||||||
|
**Type**: `string`
|
||||||
|
**Required**: No
|
||||||
|
**Default**: `0.0.0.0` (production) / `localhost` (development)
|
||||||
|
|
||||||
|
Host address for the API service to bind to. Set to `::` to enable IPv6 support (useful for platforms like Railway that use IPv6 for internal networking).
|
||||||
|
|
||||||
|
**Example**:
|
||||||
|
```bash
|
||||||
|
# Default IPv4 only
|
||||||
|
API_HOST=0.0.0.0
|
||||||
|
|
||||||
|
# IPv6 (dual-stack, accepts both IPv4 and IPv6)
|
||||||
|
API_HOST=::
|
||||||
|
```
|
||||||
|
|
||||||
|
<Callout>
|
||||||
|
Use `API_HOST=::` when deploying on platforms like Railway where private networking requires IPv6. The `::` address enables dual-stack mode, accepting both IPv4 and IPv6 connections on most systems.
|
||||||
|
</Callout>
|
||||||
|
|
||||||
## Logging
|
## Logging
|
||||||
|
|
||||||
### LOG_LEVEL
|
### LOG_LEVEL
|
||||||
|
|||||||
Reference in New Issue
Block a user