Skip to content

Commit

Permalink
update redirect positions
Browse files Browse the repository at this point in the history
  • Loading branch information
puncsky committed Jan 20, 2021
1 parent b443ac4 commit 417ecf0
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -48,19 +48,16 @@ export function isoReactRenderMiddleware(server: Server): Middleware {
</RootServer>
);

// This will contain the URL to redirect to if <Redirect> 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 <Redirect> was used
if (context.url) {
ctx.redirect(context.url);
return "";
}

return rootHtml({ styletron, jsonGlobals, reactMarkup, clientScript });
};
Expand Down

0 comments on commit 417ecf0

Please sign in to comment.