Skip to content

Commit

Permalink
rewrite old search url
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Aug 2, 2023
1 parent 67f80f6 commit b2ffd98
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/app/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ export const middleware: NextMiddleware = async (req: NextRequest) => {
const searchedCountry = req.nextUrl.pathname.split('/').at(2)
if (searchedCountry && !activeCountries?.includes(searchedCountry)) {
const url = req.nextUrl.clone()
url.searchParams.forEach((_v, k) => url.searchParams.delete(k))
url.pathname = `/search/intl/${searchedCountry}`
// url.searchParams.set('country', searchedCountry)
if (searchedCountry === 'dist') {
url.pathname = url.pathname.replace(/\/dist\//, '/US/')
} else {
url.searchParams.forEach((_v, k) => url.searchParams.delete(k))
url.pathname = `/search/intl/${searchedCountry}`
}
const redirected = NextResponse.redirect(url)
if (session) redirected.cookies.set('inreach-session', session.value)

Expand Down

1 comment on commit b2ffd98

@vercel
Copy link

@vercel vercel bot commented on b2ffd98 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.