Open
Description
Describe the bug
It's currently impossible to disable the /metrics
endpoint exposed by the @graphql-yoga/plugin-prometheus
plugin, passing endpoint: false
to the plugin's options doesn't do what one would expect it to.
I believe the issue is on this line:
const endpoint = options.endpoint || '/metrics';
Passing false
causes the "or" clause to move to the second option, i.e. the default /metrics
endpoint. I would expect this line to either use the nullish coalesce operator (??
) or some other solution which enables disabling the endpoint.
Temporary workaround
I'm currently disabling the endpoint using a simple plugin that overrides the default behavior by returning a 403 response on the path:
{
onRequest: ({ url, endResponse }) => {
if (url.pathname === '/metrics') {
return endResponse(new Response('Forbidden', { status: 403 }));
}
},
}
Your Example Website or App
N/A
Steps to Reproduce the Bug or Issue
- Use the
@graphql-yoga/plugin-prometheus
Yoga plugin - Pass the options
{ endpoint: false }
to it - Go to the
/metrics
URL in browser - The metrics data is still available
Expected behavior
- Use the
@graphql-yoga/plugin-prometheus
Yoga plugin - Pass the options
{ endpoint: false }
to it - Go to the
/metrics
URL in browser - The server shows the default Yoga landing page (or equivalent)
Screenshots or Videos
No response
Platform
N/A
Additional context
No response