13 lines
352 B
TypeScript
13 lines
352 B
TypeScript
import { Injectable, NestMiddleware } from "@nestjs/common";
|
|
import { Request, Response } from "express";
|
|
|
|
@Injectable()
|
|
export class RewriterMiddleware implements NestMiddleware {
|
|
use(req: Request, res: Response, next: () => void) {
|
|
if (req.url.startsWith("/api/v2")) {
|
|
req.url = req.url.replace("/api/v2", "/v2");
|
|
}
|
|
next();
|
|
}
|
|
}
|