From 40273c58ff8f271a80d5cfa459d804f47cdd420b Mon Sep 17 00:00:00 2001 From: wonderlandpark Date: Sat, 29 May 2021 02:22:38 +0900 Subject: [PATCH] feat: handling query string alias --- pages/search.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/search.tsx b/pages/search.tsx index bdedede..5a767bc 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -39,6 +39,7 @@ const Search:NextPage = ({ data, query }) => { } export const getServerSideProps = async(ctx: Context) => { + if(ctx.query.query && !ctx.query.q) ctx.query.q = ctx.query.query if(!ctx.query?.q) { ctx.res.statusCode = 301 ctx.res.setHeader('Location', '/') @@ -69,7 +70,8 @@ interface Context extends NextPageContext { } interface URLQuery extends ParsedUrlQuery { - q: string + q?: string + query?: string page?: string }