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

url doesn't take into consideration the setGlobalPrefix #228

Closed
iangregsondev opened this issue Jun 6, 2019 · 4 comments · Fixed by #261
Closed

url doesn't take into consideration the setGlobalPrefix #228

iangregsondev opened this issue Jun 6, 2019 · 4 comments · Fixed by #261

Comments

@iangregsondev
Copy link


[ ] Regression 
[x] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Adding the url to the terminus doesn't take into consideration . the setGlobalPrefix..

For example, i have some metrics endpoints and that can be accessed via

https://localhost:3009/api/metrics

this is because I have the following set

    app.setGlobalPrefix("api")

but terminus ignores this, and it is still available on /health and not /api/health

The reason I need this is that the root is being proxied, so I need to add any custom endpoints under /api

I have terminus configured like so

 const healthEndpoint: TerminusEndpoint = {
      healthIndicators: [],
      url: "/health"
    }

Expected behavior

For terminus to take into consideration the setGlobalPrefix

Environment


Nest version: 6.1
 
For Tooling issues:
- Node version:11
- Platform:  MAC

@BrunnerLivio
Copy link
Member

BrunnerLivio commented Jun 17, 2019

Thank you for your issue.

Sorry for taking so long. I am looking into it. I have to submit a PR first on nestjs/nest before continuing here. See nestjs/nest#2410.

@iangregsondev
Copy link
Author

No problem @BrunnerLivio , thanks for getting back to me.

@BrunnerLivio
Copy link
Member

BrunnerLivio commented Jul 1, 2019

Release 6.4.0:

Added useGlobalPrefix option - it will not take the globalPrefix as default because of backwards compatibility.

You can specify the useGlobalPrefix option in the TerminusModuleOptions or for each individual TerminusEndpoint as seen here:

const app = await NestFactory.create(ApplicationModule);
app.setGlobalPrefix('/api');

...

TerminusModule.forRoot({
  // Change the default option of all endpoints to use the global prefix
  useGlobalPrefix: true,
  endpoints: [
    {
      // Will result /liveness
      url: '/liveness',
      useGlobalPrefix: false,
      healthIndicators: []
    },
    {
      // Will result as /api/readiness 
      url: '/readiness',
      healthIndicators: []
    }
  ]
})

BrunnerLivio added a commit that referenced this issue Jul 8, 2019
@cjancsar
Copy link

cjancsar commented Feb 5, 2020

@BrunnerLivio how do you use this with TerminusModuleAsyncOptions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants