mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-22 21:06:37 +00:00
added axios client
This commit is contained in:
@@ -43,7 +43,17 @@ const environmentSchema = z.object({
|
||||
.pipe(z.number().optional()),
|
||||
EMAIL_SMTP_USER: z.string().optional(),
|
||||
EMAIL_SMTP_PASS: z.string().optional(),
|
||||
EMAIL_NOREPLY: z.string().optional(),
|
||||
EMAIL_NOREPLY: z.string().email().optional(),
|
||||
SITE_DOMAIN: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform((val) => {
|
||||
if (!val) {
|
||||
return `http://localhost:${environment.EXTERNAL_PORT}`;
|
||||
}
|
||||
return val;
|
||||
})
|
||||
.pipe(z.string().url()),
|
||||
});
|
||||
|
||||
const environment = {
|
||||
@@ -63,6 +73,7 @@ const environment = {
|
||||
EMAIL_SMTP_USER: process.env.EMAIL_SMTP_USER as string,
|
||||
EMAIL_SMTP_PASS: process.env.EMAIL_SMTP_PASS as string,
|
||||
EMAIL_NOREPLY: process.env.EMAIL_NOREPLY as string,
|
||||
SITE_DOMAIN: process.env.NEXT_PUBLIC_SITE_DOMAIN as string,
|
||||
};
|
||||
|
||||
const parsedConfig = environmentSchema.safeParse(environment);
|
||||
|
||||
@@ -7,6 +7,7 @@ import helmet from "helmet";
|
||||
import cors from "cors";
|
||||
import {
|
||||
errorHandlerMiddleware,
|
||||
notFoundMiddleware,
|
||||
rateLimitMiddleware,
|
||||
} from "@server/middlewares";
|
||||
import internal from "@server/routers/internal";
|
||||
@@ -42,6 +43,8 @@ app.prepare().then(() => {
|
||||
externalServer.use(prefix, unauthenticated);
|
||||
externalServer.use(prefix, authenticated);
|
||||
|
||||
externalServer.use(notFoundMiddleware)
|
||||
|
||||
// We are using NEXT from here on
|
||||
externalServer.all("*", (req: Request, res: Response) => {
|
||||
const parsedUrl = parse(req.url!, true);
|
||||
|
||||
@@ -7,8 +7,11 @@ export function notFoundMiddleware(
|
||||
res: Response,
|
||||
next: NextFunction,
|
||||
) {
|
||||
const message = `The requests url is not found - ${req.originalUrl}`;
|
||||
return next(createHttpError(HttpCode.NOT_FOUND, message));
|
||||
if (req.path.startsWith("/api")) {
|
||||
const message = `The requests url is not found - ${req.originalUrl}`;
|
||||
return next(createHttpError(HttpCode.NOT_FOUND, message));
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
export default notFoundMiddleware;
|
||||
|
||||
Reference in New Issue
Block a user