Skip to content

Commit 553c709

Browse files
authored
swagger UI on Production gives a 404 (#116)
1 parent 449fe96 commit 553c709

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

server/helpers/openapi.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import { env } from "../../core";
77
// to be separate unlike old implementation
88

99
export const openapi = async (server: FastifyInstance) => {
10-
if (process.env.NODE_ENV === "production") {
11-
return Promise.resolve();
12-
}
1310
await server.register(swagger, {
1411
mode: "dynamic",
1512
openapi: {

server/helpers/server.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ const createServer = async (serverName: string): Promise<FastifyInstance> => {
2626
);
2727
}
2828

29+
if (process.env.NODE_ENV === "production") {
30+
if (request.routerPath?.includes("static")) {
31+
return reply.status(404).send({
32+
statusCode: 404,
33+
error: "Not Found",
34+
message: "Not Found",
35+
});
36+
}
37+
}
38+
2939
const { url } = request;
3040
// Skip Authentication for Health Check and Static Files and JSON Files for Swagger
3141
// Doing Auth check onRequest helps prevent unauthenticated requests from consuming server resources.

0 commit comments

Comments
 (0)