Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get setGlobalPrefix value in adapter #14362

Open
3 of 15 tasks
Makkalay opened this issue Jan 4, 2025 · 4 comments
Open
3 of 15 tasks

Can't get setGlobalPrefix value in adapter #14362

Makkalay opened this issue Jan 4, 2025 · 4 comments
Labels
needs triage This issue has not been looked into

Comments

@Makkalay
Copy link
Contributor

Makkalay commented Jan 4, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

In nest-application await this.httpAdapter?.init(); no options is passed from nest app to adapter

async init() {
        await this.httpAdapter?.init();

Minimum reproduction code

https://github.com/nestjs/nest

Steps to reproduce

No response

Expected behavior

To pass to adapter this.config

async init() {
        await this.httpAdapter?.init(this.config);

and in adapter will be able to call this.config.getGlobalPrefix();

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

latest

Packages versions

latest

Node.js version

20

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

@Makkalay Makkalay added the needs triage This issue has not been looked into label Jan 4, 2025
@micalevisk
Copy link
Member

I didn't get if this is a bug report or a feature request

@kamilmysliwiec
Copy link
Member

Why do you need that?

@Makkalay
Copy link
Contributor Author

Makkalay commented Jan 5, 2025

The middleware in express way not work well, it has other aproach. And for that, I need to make some custom createMiddlewareFactory, because the path of middlewares already contains here the setGlobalPrefix and i need it to compare path

    createMiddlewareFactory(requestMethod) {
      retrun (...args) => {
         // some magic but path is /api/test and not /test
         this.middlewares.push(args)
      } 
   }

@Makkalay
Copy link
Contributor Author

Makkalay commented Jan 5, 2025

And here

get(...args) {
        // magic with middleware, filter middleware by path
       const m = this.middlewares.filter()
        return this.injectRouteOptions(common_1.RequestMethod.GET, ...args, m);
    }

Now all work well but i hardcode that prefix api that is not nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

3 participants