mirror of
https://github.com/fosrl/pangolin.git
synced 2025-12-14 12:08:11 +00:00
make rewrite data null if no match added
This commit is contained in:
@@ -183,7 +183,7 @@ function createPathRewriteMiddleware(
|
|||||||
|
|
||||||
switch (rewritePathType) {
|
switch (rewritePathType) {
|
||||||
case "exact":
|
case "exact":
|
||||||
// Replace the entire path with the exact rewrite path
|
// Replace the path with the exact rewrite path
|
||||||
let exactPattern = `^${escapeRegex(path)}$`;
|
let exactPattern = `^${escapeRegex(path)}$`;
|
||||||
middlewares[middlewareName] = {
|
middlewares[middlewareName] = {
|
||||||
replacePathRegex: {
|
replacePathRegex: {
|
||||||
@@ -549,10 +549,10 @@ export async function getTraefikConfig(
|
|||||||
config_output.http.middlewares = {};
|
config_output.http.middlewares = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the middleware(s) to the config
|
// the middleware to the config
|
||||||
Object.assign(config_output.http.middlewares, rewriteResult.middlewares);
|
Object.assign(config_output.http.middlewares, rewriteResult.middlewares);
|
||||||
|
|
||||||
// Add middleware(s) to the router middleware chain
|
// middlewares to the router middleware chain
|
||||||
if (rewriteResult.chain) {
|
if (rewriteResult.chain) {
|
||||||
// For chained middlewares (like stripPrefix + addPrefix)
|
// For chained middlewares (like stripPrefix + addPrefix)
|
||||||
routerMiddlewares.push(...rewriteResult.chain);
|
routerMiddlewares.push(...rewriteResult.chain);
|
||||||
@@ -564,7 +564,6 @@ export async function getTraefikConfig(
|
|||||||
logger.info(`Created path rewrite middleware ${rewriteMiddlewareName}: ${resource.pathMatchType}(${resource.path}) -> ${resource.rewritePathType}(${resource.rewritePath})`);
|
logger.info(`Created path rewrite middleware ${rewriteMiddlewareName}: ${resource.pathMatchType}(${resource.path}) -> ${resource.rewritePathType}(${resource.rewritePath})`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Failed to create path rewrite middleware for resource ${resource.resourceId}: ${error}`);
|
logger.error(`Failed to create path rewrite middleware for resource ${resource.resourceId}: ${error}`);
|
||||||
// Continue without the rewrite middleware rather than failing completely
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -632,6 +632,8 @@ export default function ReverseProxyTargets(props: {
|
|||||||
...row.original,
|
...row.original,
|
||||||
path: null,
|
path: null,
|
||||||
pathMatchType: null,
|
pathMatchType: null,
|
||||||
|
rewritePath: null,
|
||||||
|
rewritePathType: null
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -610,6 +610,8 @@ export default function Page() {
|
|||||||
...row.original,
|
...row.original,
|
||||||
path: null,
|
path: null,
|
||||||
pathMatchType: null,
|
pathMatchType: null,
|
||||||
|
rewritePath: null,
|
||||||
|
rewritePathType: null
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user