Skip to content

Commit 4a34a08

Browse files
authored
fix: redirect property in responseOverride doesn't behave as expected (#284)
* fix: redirect property in responseOverride doesn't behave as expected
1 parent f07d1f5 commit 4a34a08

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/core/utils/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const logger = {
4444
},
4545

4646
/**
47-
* Print error data and optionally exist the CLI instance.
47+
* Print error data and optionally exit the CLI instance.
4848
* @param data Either a string or an object to be printed.
4949
* @param exit If set to True, the CLI instance will be terminated after printing the error message (code -1).
5050
*/

src/msha/routes-engine/rules/response-overrides.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export function responseOverrides(req: http.IncomingMessage, res: http.ServerRes
2525
}
2626

2727
if (rule.redirect) {
28+
const statusCodeToServe = parseInt(`${rule?.statusCode}`, 10) === 301 ? 301 : 302;
29+
res.statusCode = statusCodeToServe;
2830
res.setHeader("Location", rule.redirect);
2931

3032
logger.silly(` - redirect: ${chalk.yellow(rule.redirect)}`);

0 commit comments

Comments
 (0)