Questions & Answers

How to change the default port of the HTTP server?

Deepkit Framework
50 up-votes
Warning: The answer is generated by an artificial intelligence. It might not be correct.
To adjust rating, open the thread in Discord and click on the up/down vote button.

There are several ways to change the port of the application server of FrameworkModule.

Change the module directly:

const app = new App({
    imports: [
        new FrameworkModule({
            port: 3000
        })
    ]
});

Load from environment variable:

const app = new App({
    imports: [
        new FrameworkModule()
    ]
});

app.loadConfigFromEnv({namingStrategy: 'same', prefix: 'app_'});
app.run();

Then start the application with the environment variable app_framework_port set to 3000.

app_framework_port=3000 ts-node app.ts server:start

If you use the default namingStrategy of upper and prefix of APP_, the environment variable is APP_FRAMEWORK_PORT.