Nest: Express set

Created on 28 May 2019  路  10Comments  路  Source: nestjs/nest

Bug Report

Current behavior


set is not being exposed in order to add custom config to express such as trust proxy

Input Code

const your = (code) => here;

Expected behavior


Being able to set express config such as trust proxy, views etc

Possible Solution

Environment


Nest version: X.Y.Z


For Tooling issues:
- Node version: XX  
- Platform:  

Others:

needs triage

Most helpful comment

There is a set method, but you have to use NestExpressApplication interface. See here https://docs.nestjs.com/first-steps#platform

const app = await NestFactory.create<NestExpressApplication>(ApplicationModule);
app.set(...)

All 10 comments

See this https://docs.nestjs.com/first-steps#platform

const app = await NestFactory.create<NestExpressApplication>(ApplicationModule);

This seems to work.. not sure if this is recommended

const server = express();

server.set('trust proxy', 1);

const app = await NestFactory.create(AppModule, new ExpressAdapter(server), {
    logger,
    httpsOptions: environment.httpsOptions,
});

That's strange because the old nestjs version had set, now it's not exposed and it's very useful for this like trust proxy

Nest should not be dependent on express.. It makes total sense

Yes but since nest uses mainly it and set is one of the most used things, there's no problem on exposing it that's what i mean

Gonna have to agree to disagree on this one 馃槈

There is a set method, but you have to use NestExpressApplication interface. See here https://docs.nestjs.com/first-steps#platform

const app = await NestFactory.create<NestExpressApplication>(ApplicationModule);
app.set(...)

this is much better than what im doing

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hackboy picture hackboy  路  3Comments

artaommahe picture artaommahe  路  3Comments

2233322 picture 2233322  路  3Comments

KamGor picture KamGor  路  3Comments

JulianBiermann picture JulianBiermann  路  3Comments