From 417ecf042ddd671ae009ee33522ae27eae4a801e Mon Sep 17 00:00:00 2001 From: Tian Pan Date: Tue, 19 Jan 2021 20:10:28 -0800 Subject: [PATCH] update redirect positions --- .../iso-react-render-middleware.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/web-server/src/iso-react-render/iso-react-render-middleware.tsx b/packages/web-server/src/iso-react-render/iso-react-render-middleware.tsx index 0ae078d4..64b1fecb 100644 --- a/packages/web-server/src/iso-react-render/iso-react-render-middleware.tsx +++ b/packages/web-server/src/iso-react-render/iso-react-render-middleware.tsx @@ -31,9 +31,9 @@ export function isoReactRenderMiddleware(server: Server): Middleware { const styletron = new StyletronServer({ prefix: "_" }); const context = { - url: undefined, + url: "", statusCode: 200, - status: 200, + status: 200 }; initClientI18n(ctx.state.view.base.translations); const reactMarkup = renderToString( @@ -48,19 +48,16 @@ export function isoReactRenderMiddleware(server: Server): Middleware { ); - // This will contain the URL to redirect to if was used - if (context.url) { - ctx.redirect( - context.statusCode ? String(context.statusCode) : "302", - context.url - ); - return ""; - } if (context.statusCode) { ctx.status = context.statusCode; } else if (context.status) { ctx.status = context.status; } + // This will contain the URL to redirect to if was used + if (context.url) { + ctx.redirect(context.url); + return ""; + } return rootHtml({ styletron, jsonGlobals, reactMarkup, clientScript }); };