Set host in Fastify

This commit is contained in:
Josef 2025-11-11 10:35:13 +01:00
parent d98d59705a
commit fe9562b596
2 changed files with 13 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import Fastify, { FastifyInstance } from "fastify"; import Fastify, { FastifyInstance, FastifyListenOptions } from "fastify";
import fastifyMultipart from "@fastify/multipart"; import fastifyMultipart from "@fastify/multipart";
import cors from '@fastify/cors'; import cors from '@fastify/cors';
@ -150,9 +150,19 @@ export class UserManagementServer
async _startServer() async _startServer()
{ {
let listenOptions:FastifyListenOptions =
{
port: this._settings.port
}
if ( ! this._settings.isDebugMode )
{
listenOptions.host = "0.0.0.0";
}
this.app.listen( this.app.listen(
{ port: this._settings.port }, listenOptions,
( error, address ) => ( error, address ) =>
{ {

View File

@ -7,6 +7,7 @@ export class UserManagementServerSettings
url:string; url:string;
port:number = 8084; port:number = 8084;
corsURLs:string[] = []; corsURLs:string[] = [];
isDebugMode:boolean = false;
// Paths // Paths
rootPath:string; rootPath:string;