Skip to content

Commit

Permalink
middleware has weird side effects (like loading whole page html as js…
Browse files Browse the repository at this point in the history
…on??) - do not use it
  • Loading branch information
tsubik committed Nov 5, 2024
1 parent bab15d8 commit 28ac8a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
16 changes: 0 additions & 16 deletions middleware.js

This file was deleted.

15 changes: 14 additions & 1 deletion pages/reset-password.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@ function ResetPassword({ url, intl }) {
);
}

ResetPassword.getInitialProps = ({ url }) => ({ url });
ResetPassword.getInitialProps = async ({ url, req, asPath, locale }) => {
if (req) {
const cookies = req.cookies;
const nextLocale = cookies['NEXT_LOCALE'] || 'en';
if (nextLocale !== 'en' && locale !== nextLocale) {
return {
redirectTo: `/${nextLocale}${asPath}`,
redirectPermanent: false
}
}
}

return { url };
}

ResetPassword.propTypes = {
url: PropTypes.shape({}).isRequired,
Expand Down

0 comments on commit 28ac8a1

Please sign in to comment.